code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
function verifyCSRFToken() {
$clean_referer = str_replace(array("http://","https://"),"//",$_SERVER["HTTP_REFERER"]);
$clean_domain = str_replace(array("http://","https://"),"//",DOMAIN);
$token = isset($_POST[$this->CSRFTokenField]) ? $_POST[$this->CSRFTokenField] : $_GET[$this->CSRFTokenField];
if (strpos($clean_referer, $clean_domain) === false || $token != $this->CSRFToken) {
$this->stop("Cross site request forgery detected.");
}
} | Compound | 4 |
public function setPageTextMatchNotRegex( array $pageTextMatchNotRegex = [] ) {
$this->pageTextMatchNotRegex = (array)$pageTextMatchNotRegex;
} | Class | 2 |
$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 |
private function resize_gd($src, $width, $height, $quality, $srcImgInfo) {
switch ($srcImgInfo['mime']) {
case 'image/gif':
if (@imagetypes() & IMG_GIF) {
$oSrcImg = @imagecreatefromgif($src);
} else {
$ermsg = 'GIF images are not supported';
}
break;
case 'image/jpeg':
if (@imagetypes() & IMG_JPG) {
$oSrcImg = @imagecreatefromjpeg($src) ;
} else {
$ermsg = 'JPEG images are not supported';
}
break;
case 'image/png':
if (@imagetypes() & IMG_PNG) {
$oSrcImg = @imagecreatefrompng($src) ;
} else {
$ermsg = 'PNG images are not supported';
}
break;
case 'image/wbmp':
if (@imagetypes() & IMG_WBMP) {
$oSrcImg = @imagecreatefromwbmp($src);
} else {
$ermsg = 'WBMP images are not supported';
}
break;
default:
$oSrcImg = false;
$ermsg = $srcImgInfo['mime'].' images are not supported';
break;
}
if ($oSrcImg && false != ($tmp = imagecreatetruecolor($width, $height))) {
if (!imagecopyresampled($tmp, $oSrcImg, 0, 0, 0, 0, $width, $height, $srcImgInfo[0], $srcImgInfo[1])) {
return false;
}
switch ($srcImgInfo['mime']) {
case 'image/gif':
imagegif($tmp, $src);
break;
case 'image/jpeg':
imagejpeg($tmp, $src, $quality);
break;
case 'image/png':
if (function_exists('imagesavealpha') && function_exists('imagealphablending')) {
imagealphablending($tmp, false);
imagesavealpha($tmp, true);
}
imagepng($tmp, $src);
break;
case 'image/wbmp':
imagewbmp($tmp, $src);
break;
}
imagedestroy($oSrcImg);
imagedestroy($tmp);
return true;
}
return false;
} | Base | 1 |
$section = new section($this->params);
} else {
notfoundController::handle_not_found();
exit;
}
if (!empty($section->id)) {
$check_id = $section->id;
} else {
$check_id = $section->parent;
}
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $check_id))) {
if (empty($section->id)) {
$section->active = 1;
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
} else { // User does not have permission to manage sections. Throw a 403
notfoundController::handle_not_authorized();
}
}
| Base | 1 |
public static function error ($vars="") {
if( isset($vars) && $vars != "" ) {
include(GX_PATH.'/inc/lib/Control/Error/'.$vars.'.control.php');
}else{
include(GX_PATH.'/inc/lib/Control/Error/404.control.php');
}
} | Compound | 4 |
public function browse() {
$params = func_get_args();
$this->path = join('/', $params);
// make sure there's a / at the end
if (substr($this->path, -1, 1) != '/')
$this->path .= '/';
//security
// we dont allow back link
if (strpos($this->path, '..') !== false) {
/*
if (Plugin::isEnabled('statistics_api')) {
$user = null;
if (AuthUser::isLoggedIn())
$user = AuthUser::getUserName();
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ($_SERVER['REMOTE_ADDR']);
$event = array('event_type' => 'hack_attempt', // simple event type identifier
'description' => __('A possible hack attempt was detected.'), // translatable description
'ipaddress' => $ip,
'username' => $user);
Observer::notify('stats_file_manager_hack_attempt', $event);
}
*/
}
$this->path = str_replace('..', '', $this->path);
// clean up nicely
$this->path = str_replace('//', '', $this->path);
// we dont allow leading slashes
$this->path = preg_replace('/^\//', '', $this->path);
$this->fullpath = FILES_DIR . '/' . $this->path;
// clean up nicely
$this->fullpath = preg_replace('/\/\//', '/', $this->fullpath);
$this->display('file_manager/views/index', array(
'dir' => $this->path,
//'files' => $this->_getListFiles()
'files' => $this->_listFiles()
));
} | Class | 2 |
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 |
$res = @unserialize ( base64_decode (str_replace ( array ( "|02" , "|01" ) , array ( "/" , "|" ) , $str ) ) ) ; | Base | 1 |
} elseif (!empty($this->params['src'])) {
if ($this->params['src'] == $loc->src) {
$this->config = $config->config;
break;
}
}
}
| Base | 1 |
function phoromatic_quit_if_invalid_input_found($input_keys = null)
{
if(empty($input_keys))
{
// Check them all if not being selective about what keys to check
$input_keys = array_keys($_REQUEST);
}
// backup as to sanitization and stripping elsewhere, safeguard namely check for things like < for fields that shouldn't have it
// plus a few simple backups as safeguards for words that really have no legit relevance within Phoromatic...
foreach(array('<', 'document.write', '../', 'onerror', 'onload', 'alert(') as $invalid_string)
{
foreach($input_keys as $key)
{
if(isset($_REQUEST[$key]) && !empty($_REQUEST[$key]))
{
foreach(pts_arrays::to_array($_REQUEST[$key]) as $val_to_check)
{
if(stripos($val_to_check, $invalid_string) !== false)
{
echo '<strong>Exited due to invalid input ( ' . $invalid_string . ') attempted:</strong> ' . htmlspecialchars($val_to_check);
exit;
}
}
}
}
}
} | Base | 1 |
function PMA_getCentralColumnsCount($db)
{
$cfgCentralColumns = PMA_centralColumnsGetParams();
if (empty($cfgCentralColumns)) {
return 0;
}
$pmadb = $cfgCentralColumns['db'];
$GLOBALS['dbi']->selectDb($pmadb, $GLOBALS['controllink']);
$central_list_table = $cfgCentralColumns['table'];
$query = 'SELECT count(db_name) FROM ' .
Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\';';
$res = $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
);
if (isset($res[0])) {
return $res[0];
} else {
return 0;
}
} | Base | 1 |
public function prepare( $query, $args ) {
if ( is_null( $query ) )
return;
// This is not meant to be foolproof -- but it will catch obviously incorrect usage.
if ( strpos( $query, '%' ) === false ) {
_doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query argument of %s must have a placeholder.' ), 'wpdb::prepare()' ), '3.9.0' );
}
$args = func_get_args();
array_shift( $args );
// If args were passed as an array (as in vsprintf), move them up
if ( isset( $args[0] ) && is_array($args[0]) )
$args = $args[0];
$query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
$query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
$query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware
$query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s
array_walk( $args, array( $this, 'escape_by_ref' ) );
return @vsprintf( $query, $args );
} | Base | 1 |
public static function modList()
{
//$mod = '';
$handle = dir(GX_MOD);
while (false !== ($entry = $handle->read())) {
if ($entry != '.' && $entry != '..') {
$dir = GX_MOD.$entry;
if (is_dir($dir) == true) {
(file_exists($dir.'/index.php')) ? $mod[] = basename($dir) : '';
}
}
}
$handle->close();
return $mod;
} | Base | 1 |
protected function cacheDir($path) {
$this->dirsCache[$path] = array();
$sql = 'SELECT f.id, f.parent_id, f.name, f.size, f.mtime AS ts, f.mime, f.read, f.write, f.locked, f.hidden, f.width, f.height, IF(ch.id, 1, 0) AS dirs
FROM '.$this->tbf.' AS f
LEFT JOIN '.$this->tbf.' AS ch ON ch.parent_id=f.id AND ch.mime="directory"
WHERE f.parent_id="'.$path.'"
GROUP BY f.id';
$res = $this->query($sql);
if ($res) {
while ($row = $res->fetch_assoc()) {
// debug($row);
$id = $row['id'];
if ($row['parent_id']) {
$row['phash'] = $this->encode($row['parent_id']);
}
if ($row['mime'] == 'directory') {
unset($row['width']);
unset($row['height']);
} else {
unset($row['dirs']);
}
unset($row['id']);
unset($row['parent_id']);
if (($stat = $this->updateCache($id, $row)) && empty($stat['hidden'])) {
$this->dirsCache[$path][] = $id;
}
}
}
return $this->dirsCache[$path];
} | Base | 1 |
public function disable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public static function mod($var) {
self::load($var);
}
| Base | 1 |
public static function validator($vars =""){
$GLOBALS['validator'] = true;
$GLOBALS['validator_js'] = $vars;
//return $editor;
}
| Base | 1 |
$iloc = expUnserialize($container->internal);
if ($db->selectObject('sectionref',"module='".$iloc->mod."' AND source='".$iloc->src."'") == null) {
// There is no sectionref for this container. Populate sectionref
if ($container->external != "N;") {
$newSecRef = new stdClass();
$newSecRef->module = $iloc->mod;
$newSecRef->source = $iloc->src;
$newSecRef->internal = '';
$newSecRef->refcount = 1;
// $newSecRef->is_original = 1;
$eloc = expUnserialize($container->external);
// $section = $db->selectObject('sectionref',"module='containermodule' AND source='".$eloc->src."'");
$section = $db->selectObject('sectionref',"module='container' AND source='".$eloc->src."'");
if (!empty($section)) {
$newSecRef->section = $section->id;
$db->insertObject($newSecRef,"sectionref");
$missing_sectionrefs[] = gt("Missing sectionref for container replaced").": ".$iloc->mod." - ".$iloc->src." - PageID #".$section->id;
} else {
$db->delete('container','id="'.$container->id.'"');
$missing_sectionrefs[] = gt("Cant' find the container page for container").": ".$iloc->mod." - ".$iloc->src.' - '.gt('deleted');
}
}
}
}
assign_to_template(array(
'missing_sectionrefs'=>$missing_sectionrefs,
));
} | Class | 2 |
public static function update($vars) {
if(is_array($vars)) {
//$slug = Typo::slugify($vars['title']);
//$vars = array_merge($vars, array('slug' => $slug));
//print_r($vars);
$id = Typo::int($_GET['id']);
$ins = array(
'table' => 'posts',
'id' => $id,
'key' => $vars
);
$post = Db::update($ins);
Hooks::run('post_sqladd_action', $vars, $id);
$pinger = Options::v('pinger');
if ($pinger != "") {
Pinger::run($pinger);
}
}
return $post;
}
| 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();
} | Class | 2 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$action = $this->actionModel->getById($this->request->getIntegerParam('action_id'));
if (! empty($action) && $this->actionModel->remove($action['id'])) {
$this->flash->success(t('Action removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this action.'));
}
$this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function getQuerySelect()
{
$R2 = 'R2_' . $this->id;
return "$R2.value AS `" . $this->name . "`";
} | Base | 1 |
public static function destroy () {
session_destroy();
unset($_SESSION['gxsess']);
}
| Base | 1 |
public static function object_votes_by_webuser($object, $object_id, $orderby='date desc', $offset=0, $limit=PHP_INT_MAX)
{
global $DB;
global $website;
$DB->queryLimit('wuv.id AS id, wuv.date AS date, wuv.webuser AS webuser, wu.username AS username',
'nv_webuser_votes wuv, nv_webusers wu',
' wuv.website = '.protect($website->id).'
AND wuv.object = '.protect($object).'
AND wuv.object_id = '.protect($object_id).'
AND wu.id = wuv.webuser',
$orderby,
$offset,
$limit);
return array($DB->result(), $DB->foundRows());
}
| Base | 1 |
public function LoadContainingTag($commit)
{
if (!$commit)
return;
$args = array();
$args[] = '--tags';
$args[] = $commit->GetHash();
$revs = explode("\n", $this->exe->Execute($commit->GetProject()->GetPath(), GIT_NAME_REV, $args));
foreach ($revs as $revline) {
if (preg_match('/^([0-9a-fA-F]{40})\s+tags\/(.+)(\^[0-9]+|\~[0-9]+)$/', $revline, $regs)) {
if ($regs[1] == $commit->GetHash()) {
return $regs[2];
}
}
}
} | Base | 1 |
protected function itemLocked($hash)
{
if (!elFinder::$commonTempPath) {
return false;
}
$lock = elFinder::$commonTempPath . DIRECTORY_SEPARATOR . $hash . '.lock';
if (file_exists($lock)) {
if (filemtime($lock) + $this->itemLockExpire < time()) {
unlink($lock);
return false;
}
return true;
}
return false;
} | Base | 1 |
function draw_vdef_preview($vdef_id) {
?>
<tr class='even'>
<td style='padding:4px'>
<pre>vdef=<?php print get_vdef($vdef_id, true);?></pre>
</td>
</tr>
<?php
} | Base | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
if ($tag['project_id'] != $project['id']) {
throw new AccessForbiddenException();
}
if ($this->tagModel->remove($tag_id)) {
$this->flash->success(t('Tag removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this tag.'));
}
$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
function draw_cdef_preview($cdef_id) {
?>
<tr class='even'>
<td style='padding:4px'>
<pre>cdef=<?php print get_cdef($cdef_id, true);?></pre>
</td>
</tr>
<?php
} | 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')
)));
} | Base | 1 |
$section = new section($this->params);
} else {
notfoundController::handle_not_found();
exit;
}
if (!empty($section->id)) {
$check_id = $section->id;
} else {
$check_id = $section->parent;
}
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $check_id))) {
if (empty($section->id)) {
$section->active = 1;
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
} else { // User does not have permission to manage sections. Throw a 403
notfoundController::handle_not_authorized();
}
}
| Base | 1 |
public function verifyDOMDocument($document)
{
$signatureNode = $this->locateSignature($document);
/**
* No signature was added, it should not fail as this is not a requirement on redirect bindings
*/
if (!$signatureNode) {
return true;
}
$this->add509Cert($this->getCertificate()->getPublicKey()->getX509Certificate());
$this->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
$this->addReference($document->documentElement, XMLSecurityDSig::SHA1, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), array('id_name' => 'ID'));
return $this->verify($this->getCertificate()->getPublicKey());
} | Base | 1 |
$body = str_replace(array("\n"), "<br />", $body);
} else {
// It's going elsewhere (doesn't like quoted-printable)
$body = str_replace(array("\n"), " -- ", $body);
}
$title = $items[$i]->title;
$msg .= "BEGIN:VEVENT\n";
$msg .= $dtstart . $dtend;
$msg .= "UID:" . $items[$i]->date_id . "\n";
$msg .= "DTSTAMP:" . date("Ymd\THis", time()) . "Z\n";
if ($title) {
$msg .= "SUMMARY:$title\n";
}
if ($body) {
$msg .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" . $body . "\n";
}
// if($link_url) { $msg .= "URL: $link_url\n";}
if (!empty($this->config['usecategories'])) {
if (!empty($items[$i]->expCat[0]->title)) {
$msg .= "CATEGORIES:".$items[$i]->expCat[0]->title."\n";
} else {
$msg .= "CATEGORIES:".$this->config['uncat']."\n";
}
}
$msg .= "END:VEVENT\n";
}
| Class | 2 |
function categoryBreadcrumb() {
// global $db, $router;
//eDebug($this->category);
/*if(isset($router->params['action']))
{
$ancestors = $this->category->pathToNode();
}else if(isset($router->params['section']))
{
$current = $db->selectObject('section',' id= '.$router->params['section']);
$ancestors[] = $current;
if( $current->parent != -1 || $current->parent != 0 )
{
while ($db->selectObject('section',' id= '.$router->params['section']);)
if ($section->id == $id) {
$current = $section;
break;
}
}
}
eDebug($sections);
$ancestors = $this->category->pathToNode();
}*/
$ancestors = $this->category->pathToNode();
// eDebug($ancestors);
assign_to_template(array(
'ancestors' => $ancestors
));
} | Class | 2 |
function searchName() { return gt('Webpage'); }
| Base | 1 |
public function getFilePath($fileName = null)
{
if ($fileName === null) {
$fileName = $this->fileName;
}
return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
} | Variant | 0 |
public function backup($type='json')
{
global $DB;
global $website;
$DB->query('SELECT * FROM nv_coupons WHERE website = '.protect($website->id), 'object');
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
private function runCallback() {
foreach ($this->records as &$record) {
if (isset($record->ref_type)) {
$refType = $record->ref_type;
if (class_exists($record->ref_type)) {
$type = new $refType();
$classinfo = new ReflectionClass($type);
if ($classinfo->hasMethod('paginationCallback')) {
$item = new $type($record->original_id);
$item->paginationCallback($record);
}
}
}
}
} | Base | 1 |
public function testNewInstanceWhenAddingHeaderThatWasNotThereBefore()
{
$r = new Response(200, ['Foo' => 'Bar']);
$r2 = $r->withAddedHeader('Baz', 'Bam');
$this->assertNotSame($r, $r2);
$this->assertEquals('Bam', $r2->getHeaderLine('Baz'));
$this->assertEquals('Bar', $r2->getHeaderLine('Foo'));
} | Base | 1 |
function headerTestController($serverPort) {
$args = array('Authorization' => 'foo');
var_dump(request(php_uname('n'), $serverPort, "test_headers.php",
[], ['PROXY' => 'foobar'], $args));
} | Class | 2 |
public static function flagLib () {
return "<link href=\"".Site::$url."/assets/css/flag-icon.min.css\" rel=\"stylesheet\">";
}
| Base | 1 |
function _getHtmlHeaderColumn($title, $name, $pageName, $entityIds, $listorder, $orderdirection, $showColumn = true)
{
$str = '';
$entity = _getEntityString($entityIds);
if ($listorder == $name) {
if (($orderdirection == '') || ($orderdirection == 'down')) {
$str = "<a href='$pageName?{$entity}orderdirection=up'><img src='" . OX::assetPath() . "/images/caret-ds.gif' border='0' alt='' title=''></a>";
} else {
$str = "<a href='$pageName?{$entity}orderdirection=down'><img src='" . OX::assetPath() . "/images/caret-u.gif' border='0' alt='' title=''></a>";
}
}
return $showColumn ? "<b><a href='$pageName?{$entity}listorder=$name'>$title</a>$str</b>" : '';
} | Base | 1 |
$module_views[$key]['name'] = gt($value['name']);
}
// look for a config form for this module's current view
// $controller->loc->mod = expModules::getControllerClassName($controller->loc->mod);
//check to see if hcview was passed along, indicating a hard-coded module
// if (!empty($controller->params['hcview'])) {
// $viewname = $controller->params['hcview'];
// } else {
// $viewname = $db->selectValue('container', 'view', "internal='".serialize($controller->loc)."'");
// }
// $viewconfig = $viewname.'.config';
// foreach ($modpaths as $path) {
// if (file_exists($path.'/'.$viewconfig)) {
// $fileparts = explode('_', $viewname);
// if ($fileparts[0]=='show'||$fileparts[0]=='showall') array_shift($fileparts);
// $module_views[$viewname]['name'] = ucwords(implode(' ', $fileparts)).' '.gt('View Configuration');
// $module_views[$viewname]['file'] =$path.'/'.$viewconfig;
// }
// }
// sort the views highest to lowest by filename
// we are reverse sorting now so our array merge
// will overwrite property..we will run array_reverse
// when we're finished to get them back in the right order
krsort($common_views);
krsort($module_views);
if (!empty($moduleconfig)) $common_views = array_merge($common_views, $moduleconfig);
$views = array_merge($common_views, $module_views);
$views = array_reverse($views);
return $views;
} | Base | 1 |
$section = new section(intval($page));
if ($section) {
// self::deleteLevel($section->id);
$section->delete();
}
}
}
| Base | 1 |
public function isMethodSafe()
{
return in_array($this->getMethod(), array('GET', 'HEAD'));
} | Base | 1 |
function build_daterange_sql($timestamp, $endtimestamp=null, $field='date', $multiday=false) {
if (empty($endtimestamp)) {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($timestamp) . ")";
} else {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($endtimestamp) . ")";
}
if ($multiday)
$date_sql .= " OR (" . expDateTime::startOfDayTimestamp($timestamp) . " BETWEEN ".$field." AND dateFinished)";
$date_sql .= ")";
return $date_sql;
}
| 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 |
protected function _copy($source, $targetDir, $name) {
$this->clearcache();
$id = $this->_joinPath($targetDir, $name);
$sql = $id > 0
? sprintf('REPLACE INTO %s (id, parent_id, name, content, size, mtime, mime, width, height, `read`, `write`, `locked`, `hidden`) (SELECT %d, %d, name, content, size, mtime, mime, width, height, `read`, `write`, `locked`, `hidden` FROM %s WHERE id=%d)', $this->tbf, $id, $this->_dirname($id), $this->tbf, $source)
: sprintf('INSERT INTO %s (parent_id, name, content, size, mtime, mime, width, height, `read`, `write`, `locked`, `hidden`) SELECT %d, "%s", content, size, %d, mime, width, height, `read`, `write`, `locked`, `hidden` FROM %s WHERE id=%d', $this->tbf, $targetDir, $this->db->real_escape_string($name), time(), $this->tbf, $source);
return $this->query($sql);
} | Base | 1 |
public function testPostRoutes($uri, $expectedVersion, $expectedController, $expectedAction, $expectedId)
{
$request = new Enlight_Controller_Request_RequestTestCase();
$request->setMethod('POST');
$response = new Enlight_Controller_Response_ResponseTestCase();
$request->setPathInfo($uri);
$this->router->assembleRoute($request, $response);
static::assertEquals($expectedController, $request->getControllerName());
static::assertEquals($expectedAction, $request->getActionName());
static::assertEquals($expectedVersion, $request->getParam('version'));
static::assertEquals($expectedId, $request->getParam('id'));
} | 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,
)));
} | Class | 2 |
public function save(){
$login_user = $this->checkLogin();
$uid = $login_user['uid'] ;
$id = I("id/d");
$member_group_id = I("member_group_id/d");
$cat_id = I("cat_id/d");
$teamItemMemberInfo = D("TeamItemMember")->where(" id = '$id' ")->find();
$item_id = $teamItemMemberInfo['item_id'] ;
$team_id = $teamItemMemberInfo['team_id'] ;
if(!$this->checkItemManage($uid , $item_id)){
$this->sendError(10303);
return ;
}
$teamInfo = D("Team")->where(" id = '$team_id' and uid = '$login_user[uid]' ")->find();
if (!$teamInfo) {
$this->sendError(10209,"无此团队或者你无管理此团队的权限");
return ;
}
if(isset($_POST['member_group_id'])){
$return = D("TeamItemMember")->where(" id = '$id' ")->save(array("member_group_id"=>$member_group_id));
}
if(isset($_POST['cat_id'])){
$return = D("TeamItemMember")->where(" id = '$id' ")->save(array("cat_id"=>$cat_id));
}
$this->sendResult($return);
} | Compound | 4 |
protected function createSubRequest($uri, Request $request)
{
$cookies = $request->cookies->all();
$server = $request->server->all();
// Override the arguments to emulate a sub-request.
// Sub-request object will point to localhost as client ip and real client ip
// will be included into trusted header for client ip
try {
if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
$currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
$server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp();
}
} catch (\InvalidArgumentException $e) {
// Do nothing
}
$server['REMOTE_ADDR'] = $this->resolveTrustedProxy();
unset($server['HTTP_IF_MODIFIED_SINCE']);
unset($server['HTTP_IF_NONE_MATCH']);
$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
if ($request->headers->has('Surrogate-Capability')) {
$subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
}
if ($session = $request->getSession()) {
$subRequest->setSession($session);
}
return $subRequest;
} | Class | 2 |
public static function navtojson() {
return json_encode(self::navhierarchy());
}
| Base | 1 |
public function remove()
{
$project = $this->getProject();
$this->checkCSRFParam();
$column_id = $this->request->getIntegerParam('column_id');
if ($this->columnModel->remove($column_id)) {
$this->flash->success(t('Column removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this column.'));
}
$this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public static function desc($vars){
if(!empty($vars)){
$desc = substr(strip_tags(htmlspecialchars_decode($vars).". ".Options::get('sitedesc')),0,150);
}else{
$desc = substr(Options::get('sitedesc'),0,150);
}
return $desc;
} | Base | 1 |
function token($str) {
$fw=$this->fw;
$str=trim(preg_replace('/\{\{(.+?)\}\}/s',trim('\1'),
$fw->compile($str)));
if (preg_match('/^(.+)(?<!\|)\|((?:\h*\w+(?:\h*[,;]?))+)$/s',
$str,$parts)) {
$str=trim($parts[1]);
foreach ($fw->split(trim($parts[2],"\xC2\xA0")) as $func)
$str=((empty($this->filter[$cmd=$func]) &&
function_exists($cmd)) ||
is_string($cmd=$this->filter($func)))?
$cmd.'('.$str.')':
'Base::instance()->'.
'call($this->filter(\''.$func.'\'),['.$str.'])';
}
return $str;
} | Class | 2 |
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();
}
}
| 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 |
$dt = date('Y-m-d', strtotime($match));
$sql = par_rep("/'$match'/", "'$dt'", $sql);
}
}
if (substr($sql, 0, 6) == "BEGIN;") {
$array = explode(";", $sql);
foreach ($array as $value) {
if ($value != "") {
$result = $connection->query($value);
if (!$result) {
$connection->query("ROLLBACK");
die(db_show_error($sql, _dbExecuteFailed, mysql_error()));
}
}
}
} else {
$result = $connection->query($sql) or die(db_show_error($sql, _dbExecuteFailed, mysql_error()));
}
break;
} | Base | 1 |
public function load_from_post()
{
$this->title = $_REQUEST['title'];
$this->file = $_REQUEST['file'];
$this->permission = intval($_REQUEST['permission']);
$this->enabled = intval($_REQUEST['enabled']);
// sections
$this->sections = array();
for($s = 0; $s < count($_REQUEST['template-sections-code']); $s++)
{
if(empty($_REQUEST['template-sections-code'][$s])) continue;
$this->sections[] = array(
'code' => $_REQUEST['template-sections-code'][$s],
'name' => $_REQUEST['template-sections-name'][$s],
'editor' => $_REQUEST['template-sections-editor'][$s],
'width' => $_REQUEST['template-sections-width'][$s]
);
}
if(empty($this->sections))
{
$this->sections = array(
0 => array(
'code' => 'id',
'name' => '#main#',
'editor' => 'tinymce',
'width' => '960'
)
);
}
$this->gallery = intval($_REQUEST['gallery']);
$this->comments = intval($_REQUEST['comments']);
$this->tags = intval($_REQUEST['tags']);
$this->statistics = intval($_REQUEST['statistics']);
}
| Base | 1 |
public static function delParam($param, $post_id) {
$sql = "DELETE FROM `posts_param` WHERE `post_id` = '{$post_id}' AND `param` = '{$param}' LIMIT 1";
$q = Db::query($sql);
if ($q) {
return true;
}else{
return false;
}
}
| Base | 1 |
public function delete_version() {
if (empty($this->params['id'])) {
flash('error', gt('The version you are trying to delete could not be found'));
}
// get the version
$version = new help_version($this->params['id']);
if (empty($version->id)) {
flash('error', gt('The version you are trying to delete could not be found'));
}
// if we have errors than lets get outta here!
if (!expQueue::isQueueEmpty('error')) expHistory::back();
// delete the version
$version->delete();
expSession::un_set('help-version');
flash('message', gt('Deleted version').' '.$version->version.' '.gt('and all documents in that version.'));
expHistory::back();
} | Class | 2 |
private function addInlineReference($id, Definition $definition, $targetId, $forConstructor)
{
list($callCount, $behavior) = $this->serviceCalls[$targetId];
while ($this->container->hasAlias($targetId)) {
$targetId = (string) $this->container->getAlias($targetId);
}
if ($id === $targetId) {
return $this->addInlineService($id, $definition, $definition);
}
if ('service_container' === $targetId || isset($this->referenceVariables[$targetId])) {
return '';
}
$hasSelfRef = isset($this->circularReferences[$id][$targetId]);
$forConstructor = $forConstructor && !isset($this->definitionVariables[$definition]);
$code = $hasSelfRef && !$forConstructor ? $this->addInlineService($id, $definition, $definition) : '';
if (isset($this->referenceVariables[$targetId]) || (2 > $callCount && (!$hasSelfRef || !$forConstructor))) {
return $code;
}
$name = $this->getNextVariableName();
$this->referenceVariables[$targetId] = new Variable($name);
$reference = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $behavior ? new Reference($targetId, $behavior) : null;
$code .= sprintf(" \$%s = %s;\n", $name, $this->getServiceCall($targetId, $reference));
if (!$hasSelfRef || !$forConstructor) {
return $code;
}
$code .= sprintf(<<<'EOTXT'
if (isset($this->%s['%s'])) {
return $this->%1$s['%2$s'];
}
EOTXT
,
'services',
$id
);
return $code;
} | Base | 1 |
function NewSectionPrompt(){
global $langmessage;
ob_start();
echo '<div class="inline_box">';
echo '<form method="post" action="'.common::GetUrl($this->title).'">';
echo '<h2>'.$langmessage['new_section_about'].'</h2>';
echo '<table class="bordered full_width">';
echo '<tr><th colspan="2">'.$langmessage['New Section'].'</th></tr>';
echo '<tr><td>';
echo $langmessage['Content Type'];
echo '</td><td>';
editing_page::SectionTypes();
echo '</td></tr>';
echo '<tr><td>';
echo $langmessage['Insert Location'];
echo '</td><td>';
echo '<label><input type="radio" name="insert" value="before" /> ';
echo $langmessage['insert_before'];
echo '</label>';
echo '<label><input type="radio" name="insert" value="after" checked="checked" /> ';
echo $langmessage['insert_after'];
echo '</label>';
echo '</td></tr>';
echo '</table>';
echo '<p>';
echo '<input type="hidden" name="last_mod" value="'.$this->fileModTime.'" />';
echo '<input type="hidden" name="section" value="'.$_GET['section'].'" />';
echo '<input type="hidden" name="cmd" value="add_section" />';
echo '<input type="submit" name="" value="'.$langmessage['save'].'" class="gpsubmit"/>';
echo ' <input type="button" name="" value="'.$langmessage['cancel'].'" class="admin_box_close gpcancel" />';
echo '</p>';
echo '</form>';
echo '</div>';
$this->contentBuffer = ob_get_clean();
} | Base | 1 |
$comments->records[$key]->avatar = $db->selectObject('user_avatar',"user_id='".$record->poster."'");
}
if (empty($this->params['config']['disable_nested_comments'])) $comments->records = self::arrangecomments($comments->records);
// eDebug($sql, true);
// count the unapproved comments
if ($require_approval == 1 && $user->isAdmin()) {
$sql = 'SELECT count(com.id) as c FROM '.$db->prefix.'expComments com ';
$sql .= 'JOIN '.$db->prefix.'content_expComments cnt ON com.id=cnt.expcomments_id ';
$sql .= 'WHERE cnt.content_id='.$this->params['content_id']." AND cnt.content_type='".$this->params['content_type']."' ";
$sql .= 'AND com.approved=0';
$unapproved = $db->countObjectsBySql($sql);
} else {
$unapproved = 0;
}
$this->config = $this->params['config'];
$type = !empty($this->params['type']) ? $this->params['type'] : gt('Comment');
$ratings = !empty($this->params['ratings']) ? true : false;
assign_to_template(array(
'comments'=>$comments,
'config'=>$this->params['config'],
'unapproved'=>$unapproved,
'content_id'=>$this->params['content_id'],
'content_type'=>$this->params['content_type'],
'user'=>$user,
'hideform'=>$this->params['hideform'],
'hidecomments'=>$this->params['hidecomments'],
'title'=>$this->params['title'],
'formtitle'=>$this->params['formtitle'],
'type'=>$type,
'ratings'=>$ratings,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
));
} | Base | 1 |
protected function curl_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
if ($outfp) {
curl_setopt($ch, CURLOPT_FILE, $outfp);
} else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
}
curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
$result = curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $outfp ? $outfp : $result;
} | Base | 1 |
public static function getId($id=''){
if(isset($id)){
$sql = sprintf("SELECT * FROM `menus` WHERE `id` = '%d' ORDER BY `order` ASC", $id);
$menus = Db::result($sql);
$n = Db::$num_rows;
}else{
$menus = '';
}
return $menus;
} | Base | 1 |
public function Reset() {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Reset() without being connected");
return false;
}
fputs($this->smtp_conn,"RSET" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
}
if($code != 250) {
$this->error =
array("error" => "RSET failed",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
}
return false;
}
return true;
} | 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)) {
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if (is_readable($path.'/'.$file) && substr($file, -4) == '.tpl' && substr($file, -14) != '.bootstrap.tpl' && substr($file, -15) != '.bootstrap3.tpl' && substr($file, -10) != '.newui.tpl') {
$filename = substr($file, 0, -4);
$views[$filename] = gt($filename);
}
}
}
}
return $views;
} | Base | 1 |
public static function publish($id) {
$id = Typo::int($id);
$ins = array(
'table' => 'posts',
'id' => $id,
'key' => array(
'status' => '1'
)
);
$post = Db::update($ins);
return $post;
}
| Base | 1 |
foreach ($day as $extevent) {
$event_cache = new stdClass();
$event_cache->feed = $extgcalurl;
$event_cache->event_id = $extevent->event_id;
$event_cache->title = $extevent->title;
$event_cache->body = $extevent->body;
$event_cache->eventdate = $extevent->eventdate->date;
if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)
$event_cache->dateFinished = $extevent->dateFinished;
if (isset($extevent->eventstart))
$event_cache->eventstart = $extevent->eventstart;
if (isset($extevent->eventend))
$event_cache->eventend = $extevent->eventend;
if (isset($extevent->is_allday))
$event_cache->is_allday = $extevent->is_allday;
$found = false;
if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries
$found = $db->selectObject('event_cache','feed="'.$extgcalurl.'" AND event_id="'.$event_cache->event_id.'" AND eventdate='.$event_cache->eventdate);
if (!$found)
$db->insertObject($event_cache,'event_cache');
}
| Base | 1 |
public function duplicateTeam(Team $team, Request $request)
{
$newTeam = clone $team;
$newTeam->setName($team->getName() . ' [COPY]');
try {
$this->repository->saveTeam($newTeam);
$this->flashSuccess('action.update.success');
return $this->redirectToRoute('admin_team_edit', ['id' => $newTeam->getId()]);
} catch (\Exception $ex) {
$this->flashUpdateException($ex);
}
return $this->redirectToRoute('admin_team');
} | Compound | 4 |
public function doConfigPageInit($page) {
$action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
//the extension we are currently displaying
$managerdisplay = isset($_REQUEST['managerdisplay'])?$_REQUEST['managerdisplay']:'';
$name = isset($_REQUEST['name'])?$_REQUEST['name']:'';
$secret = isset($_REQUEST['secret'])?$_REQUEST['secret']:'';
$deny = isset($_REQUEST['deny'])?$_REQUEST['deny']:'0.0.0.0/0.0.0.0';
$permit = isset($_REQUEST['permit'])?$_REQUEST['permit']:'127.0.0.1/255.255.255.0';
$engineinfo = engine_getinfo();
$writetimeout = isset($_REQUEST['writetimeout'])?$_REQUEST['writetimeout']:'100';
$astver = $engineinfo['version'];
//if submitting form, update database
global $amp_conf;
if($action == 'add' || $action == 'delete') {
$ampuser = $amp_conf['AMPMGRUSER'];
if($ampuser == $name) {
$action = 'conflict';
}
}
switch ($action) {
case "add":
$rights = manager_format_in($_REQUEST);
manager_add($name,$secret,$deny,$permit,$rights['read'],$rights['write'],$writetimeout);
$_REQUEST['managerdisplay'] = $name;
needreload();
break;
case "delete":
manager_del($managerdisplay);
needreload();
break;
case "edit": //just delete and re-add
manager_del($name);
$rights = manager_format_in($_REQUEST);
manager_add($name,$secret,$deny,$permit,$rights['read'],$rights['write'],$writetimeout);
needreload();
break;
case "conflict":
//do nothing we are conflicting with the FreePBX Asterisk Manager User
break;
}
} | Base | 1 |
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : ($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber())) && false ?: '_'}); | Base | 1 |
function connect() {
return $this->connectToServer($this->fields['host'], $this->fields['port'],
$this->fields['rootdn'],
Toolbox::decrypt($this->fields['rootdn_passwd'], GLPIKEY),
$this->fields['use_tls'],
$this->fields['deref_option']);
} | Base | 1 |
public function onInfoAction( $context, &$pageInfo ) {
$shortdesc = HookUtils::getShortDescription( $context->getTitle() );
if ( !$shortdesc ) {
// The page has no short description
return;
}
$pageInfo['header-basic'][] = [
$context->msg( 'shortdescription-info-label' ),
$shortdesc
];
} | Base | 1 |
public function testGetFilteredEventsDataProvider () {
TestingAuxLib::loadX2NonWebUser ();
TestingAuxLib::suLogin ('testuser');
Yii::app()->settings->historyPrivacy = null;
$profile = Profile::model()->findByAttributes(array('username' => 'testuser'));
$retVal = Events::getFilteredEventsDataProvider ($profile, true, null, false);
$dataProvider = $retVal['dataProvider'];
$events = $dataProvider->getData ();
$expectedEvents = Events::getEvents (0, 0, count ($events), $profile);
// verify events from getData
$this->assertEquals (
Yii::app()->db->createCommand ("
select id
from x2_events
where user='testuser' or visibility
order by timestamp desc, id desc
")->queryColumn (),
array_map (
function ($event) { return $event->id; },
$expectedEvents['events']
)
);
// ensure that getFilteredEventsDataProvider returns same events as getData
$this->assertEquals (
array_map (
function ($event) { return $event->id; },
$expectedEvents['events']
),
array_map (
function ($event) { return $event->id; },
$events
)
);
TestingAuxLib::restoreX2WebUser ();
} | Base | 1 |
protected function tearDown()
{
static::$functions = [];
static::$fopen = null;
static::$fread = null;
parent::tearDown();
} | Class | 2 |
public function fetchRow($sql)
{
// retrieve row
$query_id = $this->query($sql);
$record = mysql_fetch_row($this->query_id);
$this->freeResult($query_id);
return $record;
}#-#fetchArray() | 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 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 |
function reset_stats() {
// global $db;
// reset the counters
// $db->sql ('UPDATE '.$db->prefix.'banner SET impressions=0 WHERE 1');
banner::resetImpressions();
// $db->sql ('UPDATE '.$db->prefix.'banner SET clicks=0 WHERE 1');
banner::resetClicks();
// let the user know we did stuff.
flash('message', gt("Banner statistics reset."));
expHistory::back();
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$category = $this->getCategory();
$this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
)));
} | Base | 1 |
foreach ($grpusers as $u) {
$emails[$u->email] = trim(user::getUserAttribution($u->id));
}
| Base | 1 |
function phoromatic_error_page($title, $description)
{
echo phoromatic_webui_header(array(''), '');
$box = '<h1>' . $title . '</h1>
<h2>' . $description . '</h2>
<p>To fix this error, try <a onclick="javascript:window.history.back();">returning to the previous page</a>. Still having problems? Consider <a href="https://github.com/phoronix-test-suite/phoronix-test-suite/issues?state=open">opening a GitHub issue report</a>; commercial support customers should contact Phoronix Media.</p><hr /><hr />';
echo phoromatic_webui_box($box);
echo phoromatic_webui_footer();
} | Base | 1 |
$tableBody[] = array($row['label'], $row['nb_visits'], $row['bounce_rate']);
if ($count == 10) break;
}
$this->table($tableHead, $tableBody, null);
}
} | Base | 1 |
public function beforeFilter() { // TODO REMOVE
parent::beforeFilter();
$this->Security->unlockedActions = array('saveElementSorting', 'populateEventFromTemplate', 'uploadFile', 'deleteTemporaryFile');
} | Base | 1 |
function twig_array_reduce(Environment $env, $array, $arrow, $initial = null)
{
if (!$arrow instanceof Closure && $env->hasExtension('\Twig\Extension\SandboxExtension') && $env->getExtension('\Twig\Extension\SandboxExtension')->isSandboxed()) {
throw new RuntimeError('The callable passed to the "reduce" filter must be a Closure in sandbox mode.');
}
if (!\is_array($array)) {
if (!$array instanceof \Traversable) {
throw new RuntimeError(sprintf('The "reduce" filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($array)));
}
$array = iterator_to_array($array);
}
return array_reduce($array, $arrow, $initial);
} | Class | 2 |
* function my_query_args_filter( $field_query ) {
* // your code here
* return $field_query;
* } | Base | 1 |
public function remove()
{
$project = $this->getProject();
$this->checkCSRFParam();
$column_id = $this->request->getIntegerParam('column_id');
if ($this->columnModel->remove($column_id)) {
$this->flash->success(t('Column removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this column.'));
}
$this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));
} | 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 |
$f = function (\Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber $v) { return $v; }; return $f(${($_ = isset($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber']) ? $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] : ($this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber())) && false ?: '_'}); | Base | 1 |
public function getIterator()
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
return new \ArrayIterator($this->all());
} | Base | 1 |
public function getUpcoming(){
$url = "http://api.themoviedb.org/3/movie/upcoming?api_key=".$this->apikey;
$upcoming = $this->curl($url);
return $upcoming;
}
| Base | 1 |
function update() {
parent::update();
expSession::clearAllUsersSessionCache('navigation');
}
| Base | 1 |
function csrf_get_tokens()
{
$has_cookies = !empty($_COOKIE);
// $ip implements a composite key, which is sent if the user hasn't sent
// any cookies. It may or may not be used, depending on whether or not
// the cookies "stick"
$secret = csrf_get_secret();
if (!$has_cookies && $secret) {
// :TODO: Harden this against proxy-spoofing attacks
$ip = ';ip:' . csrf_hash($_SERVER['IP_ADDRESS']);
} else {
$ip = '';
}
csrf_start();
// These are "strong" algorithms that don't require per se a secret
if (session_id()) {
return 'sid:' . csrf_hash(session_id()) . $ip;
}
if ($GLOBALS['csrf']['cookie']) {
$val = csrf_generate_secret();
setcookie($GLOBALS['csrf']['cookie'], $val);
return 'cookie:' . csrf_hash($val) . $ip;
}
if ($GLOBALS['csrf']['key']) {
return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip;
}
// These further algorithms require a server-side secret
if (!$secret) {
return 'invalid';
}
if ($GLOBALS['csrf']['user'] !== false) {
return 'user:' . csrf_hash($GLOBALS['csrf']['user']);
}
if ($GLOBALS['csrf']['allow-ip']) {
return ltrim($ip, ';');
}
return 'invalid';
} | Compound | 4 |
static function description() { return gt("Places navigation links/menus on the page."); }
| Base | 1 |
} elseif (!empty($this->params['src'])) {
if ($this->params['src'] == $loc->src) {
$this->config = $config->config;
break;
}
}
}
| 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 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.