code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
function updateBasicSettings(PDFStructure &$structure) {
// set headline
if (isset($_POST['headline'])) {
$structure->setTitle(str_replace('<', '', str_replace('>', '', $_POST['headline'])));
}
// set logo
if (isset($_POST['logoFile'])) {
$structure->setLogo($_POST['logoFile']);
}
// set folding marks
if (isset($_POST['foldingmarks'])) {
$structure->setFoldingMarks($_POST['foldingmarks']);
}
} | Base | 1 |
public function approve_submit() {
global $history;
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for comment to approve'));
$lastUrl = expHistory::getLast('editable');
}
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
$simplenote = new expSimpleNote($this->params['id']);
//FIXME here is where we might sanitize the note before approving it
$simplenote->body = $this->params['body'];
$simplenote->approved = $this->params['approved'];
$simplenote->save();
$lastUrl = makelink($history->history[$history->history['lasts']['type']][count($history->history[$history->history['lasts']['type']])-1]['params']);
if (!empty($this->params['tab']))
{
$lastUrl .= "#".$this->params['tab'];
}
redirect_to($lastUrl);
} | Base | 1 |
public function onRouteShutdown(Enlight_Controller_EventArgs $args)
{
$request = $args->getRequest();
$response = $args->getResponse();
if (Shopware()->Container()->initialized('shop')) {
/** @var DetachedShop $shop */
$shop = $this->get('shop');
if ($request->getHttpHost() !== $shop->getHost()) {
if ($request->isSecure()) {
$newPath = 'https://' . $shop->getHost() . $request->getRequestUri();
} else {
$newPath = 'http://' . $shop->getHost() . $shop->getBaseUrl();
}
}
// Strip /shopware.php/ from string and perform a redirect
$preferBasePath = $this->get(Shopware_Components_Config::class)->preferBasePath;
if ($preferBasePath && strpos($request->getPathInfo(), '/shopware.php/') === 0) {
$removePath = $request->getBasePath() . '/shopware.php';
$newPath = str_replace($removePath, $request->getBasePath(), $request->getRequestUri());
}
if (isset($newPath)) {
// reset the cookie so only one valid cookie will be set IE11 fix
$basePath = $shop->getBasePath();
if ($basePath === null || $basePath === '') {
$basePath = '/';
}
$response->headers->setCookie(new Cookie('session-' . $shop->getId(), '', 1, $basePath));
$response->setRedirect($newPath, 301);
} else {
$this->upgradeShop($request, $response);
$this->initServiceMode($request);
}
$this->get(ContextServiceInterface::class)->initializeShopContext();
}
} | Base | 1 |
protected function checkTrustedHostPattern()
{
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] === GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL) {
$this->messageQueue->enqueue(new FlashMessage(
'Trusted hosts pattern is configured to allow all header values. Check the pattern defined in Admin'
. ' Tools -> Settings -> Configure Installation-Wide Options -> System -> trustedHostsPattern'
. ' and adapt it to expected host value(s).',
'Trusted hosts pattern is insecure',
FlashMessage::WARNING
));
} else {
if (GeneralUtility::hostHeaderValueMatchesTrustedHostsPattern($_SERVER['HTTP_HOST'])) {
$this->messageQueue->enqueue(new FlashMessage(
'',
'Trusted hosts pattern is configured to allow current host value.'
));
} else {
$this->messageQueue->enqueue(new FlashMessage(
'The trusted hosts pattern will be configured to allow all header values. This is because your $SERVER_NAME:$SERVER_PORT'
. ' is "' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '" while your HTTP_HOST is "'
. $_SERVER['HTTP_HOST'] . '". Check the pattern defined in Admin'
. ' Tools -> Settings -> Configure Installation-Wide Options -> System -> trustedHostsPattern'
. ' and adapt it to expected host value(s).',
'Trusted hosts pattern mismatch',
FlashMessage::ERROR
));
}
}
} | Class | 2 |
public function createDatabase($dbname = null)
{
Database::query("CREATE DATABASE `" . $dbname . "`");
} | Base | 1 |
public function showall() {
expHistory::set('viewable', $this->params);
$hv = new help_version();
//$current_version = $hv->find('first', 'is_current=1');
$ref_version = $hv->find('first', 'version=\''.$this->help_version.'\'');
// pagination parameter..hard coded for now.
$where = $this->aggregateWhereClause();
$where .= 'AND help_version_id='.(empty($ref_version->id)?'0':$ref_version->id); | Base | 1 |
$parameter = strtolower( $parameter ); //Force lower case for ease of use.
if ( empty( $parameter ) || substr( $parameter, 0, 1 ) == '#' || ( $this->parameters->exists( $parameter ) && !$this->parameters->testRichness( $parameter ) ) ) {
continue;
}
if ( !$this->parameters->exists( $parameter ) ) {
$this->logger->addMessage( \DynamicPageListHooks::WARN_UNKNOWNPARAM, $parameter, implode( ', ', $this->parameters->getParametersForRichness() ) );
continue;
}
//Ignore parameter settings without argument (except namespace and category).
if ( !strlen( $option ) ) {
if ( $parameter != 'namespace' && $parameter != 'notnamespace' && $parameter != 'category' && $this->parameters->exists( $parameter ) ) {
continue;
}
}
$parameters[$parameter][] = $option;
}
return $parameters;
} | Class | 2 |
public function getFilesInFolder(Folder $folder, $start = 0, $maxNumberOfItems = 0, $useFilters = true, $recursive = false, $sort = '', $sortRev = false)
{
$this->assureFolderReadPermission($folder);
$rows = $this->getFileIndexRepository()->findByFolder($folder);
$filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
$fileIdentifiers = array_values($this->driver->getFilesInFolder($folder->getIdentifier(), $start, $maxNumberOfItems, $recursive, $filters, $sort, $sortRev));
$items = [];
foreach ($fileIdentifiers as $identifier) {
if (isset($rows[$identifier])) {
$fileObject = $this->getFileFactory()->getFileObject($rows[$identifier]['uid'], $rows[$identifier]);
} else {
$fileObject = $this->getFileByIdentifier($identifier);
}
if ($fileObject instanceof FileInterface) {
$key = $fileObject->getName();
while (isset($items[$key])) {
$key .= 'z';
}
$items[$key] = $fileObject;
}
}
return $items;
} | Base | 1 |
foreach ($criteria as $criterion) {
// recursive call
if (isset($criterion['criteria'])) {
return $check_criteria($criterion['criteria']);
}
if (!isset($criterion['field']) || !isset($criterion['searchtype'])
|| !isset($criterion['value'])) {
return __("Malformed search criteria");
}
if (!ctype_digit((string) $criterion['field'])
|| !array_key_exists($criterion['field'], $soptions)) {
return __("Bad field ID in search criteria");
}
if (isset($soptions[$criterion['field']])
&& isset($soptions[$criterion['field']]['nosearch'])
&& $soptions[$criterion['field']]['nosearch']) {
return __("Forbidden field ID in search criteria");
}
} | Base | 1 |
static function convertXMLFeedSafeChar($str) {
$str = str_replace("<br>","",$str);
$str = str_replace("</br>","",$str);
$str = str_replace("<br/>","",$str);
$str = str_replace("<br />","",$str);
$str = str_replace(""",'"',$str);
$str = str_replace("'","'",$str);
$str = str_replace("’","'",$str);
$str = str_replace("‘","'",$str);
$str = str_replace("®","",$str);
$str = str_replace("�","-", $str);
$str = str_replace("�","-", $str);
$str = str_replace("�", '"', $str);
$str = str_replace("”",'"', $str);
$str = str_replace("�", '"', $str);
$str = str_replace("“",'"', $str);
$str = str_replace("\r\n"," ",$str);
$str = str_replace("�"," 1/4",$str);
$str = str_replace("¼"," 1/4", $str);
$str = str_replace("�"," 1/2",$str);
$str = str_replace("½"," 1/2",$str);
$str = str_replace("�"," 3/4",$str);
$str = str_replace("¾"," 3/4",$str);
$str = str_replace("�", "(TM)", $str);
$str = str_replace("™","(TM)", $str);
$str = str_replace("®","(R)", $str);
$str = str_replace("�","(R)",$str);
$str = str_replace("&","&",$str);
$str = str_replace(">",">",$str);
return trim($str);
} | Base | 1 |
$rndString = function ($len = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $len; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}; | Class | 2 |
public function event()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id'])) {
return $this->create();
}
return $this->response->html($this->template->render('action_creation/event', array(
'values' => $values,
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | Class | 2 |
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;
}
} | Base | 1 |
public function setCallback($callback)
{
if (!is_callable($callback)) {
throw new \LogicException('The Response callback must be a valid PHP callable.');
}
$this->callback = $callback;
} | Base | 1 |
$banner->increaseImpressions();
}
}
// assign banner to the template and show it!
assign_to_template(array(
'banners'=>$banners
));
} | Base | 1 |
$src = substr($ref->source, strlen($prefix)) . $section->id;
if (call_user_func(array($ref->module, 'hasContent'))) {
$oloc = expCore::makeLocation($ref->module, $ref->source);
$nloc = expCore::makeLocation($ref->module, $src);
if ($ref->module != "container") {
call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc);
} else {
call_user_func(array($ref->module, 'copyContent'), $oloc, $nloc, $section->id);
}
}
}
| 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 |
public static function update($vars){
if(is_array($vars)){
$sql = array(
'table' => 'menus',
'id' => $vars['id'],
'key' => $vars['key']
);
$menu = Db::update($sql);
}
}
| Base | 1 |
public function getQueryGroupby()
{
$R1 = 'R1_' . $this->id;
$R2 = 'R2_' . $this->id;
return "$R2.value";
} | Base | 1 |
public function downloadfile() {
if (empty($this->params['fileid'])) {
flash('error', gt('There was an error while trying to download your file. No File Specified.'));
expHistory::back();
}
$fd = new filedownload($this->params['fileid']);
if (empty($this->params['filenum'])) $this->params['filenum'] = 0;
if (empty($fd->expFile['downloadable'][$this->params['filenum']]->id)) {
flash('error', gt('There was an error while trying to download your file. The file you were looking for could not be found.'));
expHistory::back();
}
$fd->downloads++;
$fd->save();
// this will set the id to the id of the actual file..makes the download go right.
$this->params['id'] = $fd->expFile['downloadable'][$this->params['filenum']]->id;
parent::downloadfile();
} | Class | 2 |
public function getQueryOrderby()
{
return $this->name;
} | 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 |
static function displayname() {
return gt("e-Commerce Category Manager");
} | Base | 1 |
public static function getHelpVersionId($version) {
global $db;
return $db->selectValue('help_version', 'id', 'version="'.$version.'"');
} | Class | 2 |
public function getQueryGroupby()
{
$R = 'R_' . $this->id;
return "$R.value_id";
} | Base | 1 |
function ac_sigleid($name, $id) {
global $cms_db, $sess;
$sess->gc( true );
$ret = true;
if( $id >= 1 ) {
$ret = false;
$cquery = sprintf("select count(*) from %s where user_id='%s' and name='%s'",
$cms_db['sessions'],
$id,
$name);
$squery = sprintf("select sid from %s where user_id='%s' and name='%s'",
$cms_db['sessions'],
$id,
addslashes($name));
$this->db->query($squery);
if ( $this->db->affected_rows() == 0
&& $this->db->query($cquery)
&& $this->db->next_record() && $this->db->f(0) == 0 ) {
// nothing found here
$ret = true;
}
}
return $ret;
} | Base | 1 |
$this->_writeBackup($tmpDir . 'plugin' . DS, $plugin['Plugin']['name'], $encoding);
}
}
// ZIP圧縮して出力
$fileName = 'baserbackup_' . $version . '_' . date('Ymd_His');
$Simplezip = new Simplezip();
$Simplezip->addFolder($tmpDir);
$Simplezip->download($fileName);
$this->_resetTmpSchemaFolder();
exit();
} | Base | 1 |
public static function get_param($key = NULL) {
$info = [
'stype' => htmlentities(self::$search_type),
'stext' => htmlentities(self::$search_text),
'method' => htmlentities(self::$search_method),
'datelimit' => self::$search_date_limit,
'fields' => self::$search_fields,
'sort' => self::$search_sort,
'chars' => htmlentities(self::$search_chars),
'order' => self::$search_order,
'forum_id' => self::$forum_id,
'memory_limit' => self::$memory_limit,
'composevars' => self::$composevars,
'rowstart' => self::$rowstart,
'search_param' => htmlentities(self::$search_param),
];
return $key === NULL ? $info : (isset($info[$key]) ? $info[$key] : NULL);
} | Compound | 4 |
foreach ($page as $pageperm) {
if (!empty($pageperm['manage'])) return true;
}
| Class | 2 |
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 |
public function rules()
{
$rules = [
// 'title' => 'required', // todo with multilanguage
];
return $rules;
} | Base | 1 |
public function setContainer($container)
{
$this->container = $container;
$container->setType('ctLinks');
} | 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'])));
} | Class | 2 |
public function configure() {
$this->config['defaultbanner'] = array();
if (!empty($this->config['defaultbanner_id'])) {
$this->config['defaultbanner'][] = new expFile($this->config['defaultbanner_id']);
}
parent::configure();
$banners = $this->banner->find('all', null, 'companies_id');
assign_to_template(array(
'banners'=>$banners,
'title'=>static::displayname()
));
} | Class | 2 |
public function column_title( $post ) {
list( $mime ) = explode( '/', $post->post_mime_type );
$title = _draft_or_post_title();
$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
$link_start = $link_end = '';
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
$link_start = sprintf(
'<a href="%s" aria-label="%s">',
get_edit_post_link( $post->ID ),
/* translators: %s: attachment title */
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) )
);
$link_end = '</a>';
}
$class = $thumb ? ' class="has-media-icon"' : '';
?>
<strong<?php echo $class; ?>>
<?php
echo $link_start;
if ( $thumb ) : ?>
<span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
<?php endif;
echo $title . $link_end;
_media_states( $post );
?>
</strong>
<p class="filename">
<span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span>
<?php
$file = get_attached_file( $post->ID );
echo wp_basename( $file );
?>
</p>
<?php
} | Base | 1 |
public static function getSubcategories( $categoryName, $depth = 1 ) {
$DB = wfGetDB( DB_REPLICA, 'dpl' );
if ( $depth > 2 ) {
//Hard constrain depth because lots of recursion is bad.
$depth = 2;
}
$categories = [];
$result = $DB->select(
[ 'page', 'categorylinks' ],
[ 'page_title' ],
[
'page_namespace' => intval( NS_CATEGORY ),
'categorylinks.cl_to' => str_replace( ' ', '_', $categoryName )
],
__METHOD__,
[ 'DISTINCT' ],
[
'categorylinks' => [
'INNER JOIN',
'page.page_id = categorylinks.cl_from'
]
]
);
while ( $row = $result->fetchRow() ) {
$categories[] = $row['page_title'];
if ( $depth > 1 ) {
$categories = array_merge( $categories, self::getSubcategories( $row['page_title'], $depth - 1 ) );
}
}
$categories = array_unique( $categories );
$DB->freeResult( $result );
return $categories;
} | Class | 2 |
$q = self::$mysqli->query($vars) ;
if($q === false) {
user_error("Query failed: ".self::$mysqli->error."<br />\n$vars");
return false;
}
}
return $q;
} | Base | 1 |
function get_allowed_files_extensions_for_upload($fileTypes = 'images')
{
$are_allowed = '';
switch ($fileTypes) {
case 'img':
case 'image':
case 'images':
$are_allowed .= ',png,gif,jpg,jpeg,tiff,bmp,svg';
break;
case 'video':
case 'videos':
$are_allowed .= ',avi,asf,mpg,mpeg,mp4,flv,mkv,webm,ogg,wma,mov,wmv';
break;
case 'file':
case 'files':
$are_allowed .= ',doc,docx,pdf,html,js,css,htm,rtf,txt,zip,gzip,rar,cad,xml,psd,xlsx,csv,7z';
break;
case 'documents':
case 'doc':
$are_allowed .= ',doc,docx,pdf,log,msg,odt,pages,rtf,tex,txt,wpd,wps,pps,ppt,pptx,xml,htm,html,xlr,xls,xlsx';
break;
case 'archives':
case 'arc':
case 'arch':
$are_allowed .= ',zip,zipx,gzip,rar,gz,7z,cbr,tar.gz';
break;
case 'all':
$are_allowed .= ',*';
break;
case '*':
$are_allowed .= ',*';
break;
default:
$are_allowed .= ',' . $fileTypes;
}
if($are_allowed){
$are_allowed = explode(',',$are_allowed);
array_unique($are_allowed);
$are_allowed = array_filter($are_allowed);
$are_allowed = implode(',', $are_allowed);
}
return $are_allowed;
} | Base | 1 |
function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
if ( -1 == $action ) {
_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2.0' );
}
$adminurl = strtolower( admin_url() );
$referer = strtolower( wp_get_referer() );
$result = isset( $_REQUEST[ $query_arg ] ) ? wp_verify_nonce( $_REQUEST[ $query_arg ], $action ) : false;
/**
* Fires once the admin request has been validated or not.
*
* @since 1.5.1
*
* @param string $action The nonce action.
* @param false|int $result False if the nonce is invalid, 1 if the nonce is valid and generated between
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
*/
do_action( 'check_admin_referer', $action, $result );
if ( ! $result && ! ( -1 == $action && strpos( $referer, $adminurl ) === 0 ) ) {
wp_nonce_ays( $action );
die();
}
return $result;
} | Base | 1 |
public function showall() {
expHistory::set('viewable', $this->params);
$hv = new help_version();
//$current_version = $hv->find('first', 'is_current=1');
$ref_version = $hv->find('first', 'version=\''.$this->help_version.'\'');
// pagination parameter..hard coded for now.
$where = $this->aggregateWhereClause();
$where .= 'AND help_version_id='.(empty($ref_version->id)?'0':$ref_version->id); | Base | 1 |
private function sendString ($string) {
$bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
return $bytes_sent;
} | Class | 2 |
public static function go($input, $path, $allowed='', $uniq=false, $size='', $width = '', $height = ''){
$filename = Typo::cleanX($_FILES[$input]['name']);
$filename = str_replace(' ', '_', $filename);
if(isset($_FILES[$input]) && $_FILES[$input]['error'] == 0){
if($uniq == true){
$site = Typo::slugify(Options::v('sitename'));
$uniqfile = $site.'-'.sha1(microtime().$filename).'-';
}else{
$uniqfile = '';
}
$extension = pathinfo($_FILES[$input]['name'], PATHINFO_EXTENSION);
$filetmp = $_FILES[$input]['tmp_name'];
$filepath = GX_PATH.$path.$uniqfile.$filename;
if(!in_array(strtolower($extension), $allowed)){
$result['error'] = 'File not allowed';
}else{
if(move_uploaded_file(
$filetmp,
$filepath)
){
$result['filesize'] = filesize($filepath);
$result['filename'] = $uniqfile.$filename;
$result['path'] = $path.$uniqfile.$filename;
$result['filepath'] = $filepath;
$result['fileurl'] = Site::$url.$path.$uniqfile.$filename;
}else{
$result['error'] = 'Cannot upload to directory, please check
if directory is exist or You had permission to write it.';
}
}
}else{
//$result['error'] = $_FILES[$input]['error'];
$result['error'] = '';
}
return $result;
}
| Base | 1 |
} elseif (!empty($this->params['src'])) {
if ($this->params['src'] == $loc->src) {
$this->config = $config->config;
break;
}
}
}
| Base | 1 |
public function archive(){
$login_user = $this->checkLogin();
$item_id = I("item_id/d");
$password = I("password");
$item = D("Item")->where("item_id = '$item_id' ")->find();
if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
$this->sendError(10303);
return ;
}
if(! D("User")-> checkLogin($item['username'],$password)){
$this->sendError(10208);
return ;
}
$return = D("Item")->where("item_id = '$item_id' ")->save(array("is_archived"=>1));
if (!$return) {
$this->sendError(10101);
}else{
$this->sendResult($return);
}
} | Compound | 4 |
public function request($method, $uri = null, array $options = [])
{
$options[RequestOptions::SYNCHRONOUS] = true;
return $this->requestAsync($method, $uri, $options)->wait();
} | Base | 1 |
function can_process() {
$Auth_Result = hook_authenticate($_SESSION['wa_current_user']->username, $_POST['cur_password']);
if (!isset($Auth_Result)) // if not used external login: standard method
$Auth_Result = get_user_auth($_SESSION['wa_current_user']->username, md5($_POST['cur_password']));
if (!$Auth_Result) {
display_error( _('Invalid password entered.'));
set_focus('cur_password');
return false;
}
if (strlen($_POST['password']) < 4) {
display_error( _('The password entered must be at least 4 characters long.'));
set_focus('password');
return false;
}
if (strstr($_POST['password'], $_SESSION['wa_current_user']->username) != false) {
display_error( _('The password cannot contain the user login.'));
set_focus('password');
return false;
}
if ($_POST['password'] != $_POST['passwordConfirm']) {
display_error( _('The passwords entered are not the same.'));
set_focus('password');
return false;
}
return true;
} | Base | 1 |
public function getPurchaseOrderByJSON() {
if(!empty($this->params['vendor'])) {
$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);
} else {
$purchase_orders = $this->purchase_order->find('all');
}
echo json_encode($purchase_orders);
} | Base | 1 |
function display_error_block() {
if (!empty($_SESSION['error_msg'])) {
echo '
<div>
<script type="text/javascript">
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
<div id="dialog-message" title="">
<p>'. $_SESSION['error_msg'] .'</p>
</div>
</div>'."\n";
unset($_SESSION['error_msg']);
}
} | Compound | 4 |
public function downloadfile() {
if (empty($this->params['fileid'])) {
flash('error', gt('There was an error while trying to download your file. No File Specified.'));
expHistory::back();
}
$fd = new filedownload($this->params['fileid']);
if (empty($this->params['filenum'])) $this->params['filenum'] = 0;
if (empty($fd->expFile['downloadable'][$this->params['filenum']]->id)) {
flash('error', gt('There was an error while trying to download your file. The file you were looking for could not be found.'));
expHistory::back();
}
$fd->downloads++;
$fd->save();
// this will set the id to the id of the actual file..makes the download go right.
$this->params['id'] = $fd->expFile['downloadable'][$this->params['filenum']]->id;
parent::downloadfile();
} | Base | 1 |
protected function _archive($dir, $files, $name, $arc)
{
// get current directory
$cwd = getcwd();
$tmpDir = $this->tempDir();
if (!$tmpDir) {
return false;
}
//download data
if (!$this->ftp_download_files($dir, $files, $tmpDir)) {
//cleanup
$this->rmdirRecursive($tmpDir);
return false;
}
$remoteArchiveFile = false;
if ($path = $this->makeArchive($tmpDir, $files, $name, $arc)) {
$remoteArchiveFile = $this->_joinPath($dir, $name);
if (!ftp_put($this->connect, $remoteArchiveFile, $path, FTP_BINARY)) {
$remoteArchiveFile = false;
}
}
//cleanup
if(!$this->rmdirRecursive($tmpDir)) {
return false;
}
return $remoteArchiveFile;
} | Base | 1 |
$link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));
| Base | 1 |
$res = @unserialize ( base64_decode (str_replace ( array ( "|02" , "|01" ) , array ( "/" , "|" ) , $str ) ) ) ; | Base | 1 |
static function encrypt($string, $key) {
$result = '';
for ($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result .= $char;
}
return base64_encode($result);
} | Class | 2 |
static function validUTF($string) {
if(!mb_check_encoding($string, 'UTF-8') OR !($string === mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {
return false;
}
return true;
} | Class | 2 |
function _makeMpName($value) {
if ($value != '') {
$get_name = DBGet(DBQuery('SELECT TITLE FROM marking_periods WHERE marking_period_id=' . $value));
return $get_name[1]['TITLE'];
} else
return ''._customCoursePeriod.'';
} | Base | 1 |
foreach ($fields as $field) {
$fieldName = $field->fieldName;
if ($field->type == 'date' || $field->type == 'dateTime') {
if (is_numeric($record->$fieldName))
$record->$fieldName = Formatter::formatLongDateTime($record->$fieldName);
}elseif ($field->type == 'link') {
$name = $record->$fieldName;
if (!empty($field->linkType)) {
list($name, $id) = Fields::nameAndId($name);
}
if (!empty($name))
$record->$fieldName = $name;
}elseif ($fieldName == 'visibility') {
$record->$fieldName = $record->$fieldName == 1 ? 'Public' : 'Private';
}
} | 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,
));
} | Class | 2 |
public function getModel()
{
return $this->model;
} | Base | 1 |
public function setModelAttributes(&$model,&$attributeList,&$params) {
$data = array ();
foreach($attributeList as &$attr) {
if(!isset($attr['name'],$attr['value']))
continue;
if(null !== $field = $model->getField($attr['name'])) {
// first do variable/expression evaluation, // then process with X2Fields::parseValue()
$type = $field->type;
$value = $attr['value'];
if(is_string($value)){
if(strpos($value, '=') === 0){
$evald = X2FlowFormatter::parseFormula($value, $params);
if(!$evald[0])
return false;
$value = $evald[1];
} elseif($params !== null){
if(is_string($value) && isset($params['model'])){
$value = X2FlowFormatter::replaceVariables(
$value, $params['model'], $type);
}
}
}
$data[$attr['name']] = $value;
}
}
if (!isset ($model->scenario))
$model->setScenario ('X2Flow');
$model->setX2Fields ($data);
if ($model instanceof Actions && isset($data['complete'])) {
switch($data['complete']) {
case 'Yes':
$model->complete();
break;
case 'No':
$model->uncomplete();
break;
}
}
return true;
} | Class | 2 |
function XMLRPCremoveImageGroupFromComputerGroup($imageGroup, $computerGroup){
$imageid = getResourceGroupID("image/$imageGroup");
$compid = getResourceGroupID("computer/$computerGroup");
if($imageid && $compid){
$tmp = getUserResources(array("imageAdmin"),
array("manageMapping"), 1);
$imagegroups = $tmp['image'];
$tmp = getUserResources(array("computerAdmin"),
array("manageMapping"), 1);
$computergroups = $tmp['computer'];
if(array_key_exists($compid, $computergroups) &&
array_key_exists($imageid, $imagegroups)){
$mapping = getResourceMapping("image", "computer",
$imageid,
$compid);
if(array_key_exists($imageid, $mapping) &&
array_key_exists($compid, $mapping[$imageid])){
$query = "DELETE FROM resourcemap "
. "WHERE resourcegroupid1 = $imageid AND "
. "resourcetypeid1 = 13 AND "
. "resourcegroupid2 = $compid AND "
. "resourcetypeid2 = 12";
doQuery($query, 101);
}
return array('status' => 'success');
} else {
return array('status' => 'error',
'errorcode' => 84,
'errormsg' => 'cannot access computer and/or image group');
}
} else {
return array('status' => 'error',
'errorcode' => 83,
'errormsg' => 'invalid resource group name');
}
} | Class | 2 |
public function downloadfile() {
if (empty($this->params['fileid'])) {
flash('error', gt('There was an error while trying to download your file. No File Specified.'));
expHistory::back();
}
$fd = new filedownload($this->params['fileid']);
if (empty($this->params['filenum'])) $this->params['filenum'] = 0;
if (empty($fd->expFile['downloadable'][$this->params['filenum']]->id)) {
flash('error', gt('There was an error while trying to download your file. The file you were looking for could not be found.'));
expHistory::back();
}
$fd->downloads++;
$fd->save();
// this will set the id to the id of the actual file..makes the download go right.
$this->params['id'] = $fd->expFile['downloadable'][$this->params['filenum']]->id;
parent::downloadfile();
} | Base | 1 |
public function destroy(Appointment $appointment)
{
if (!auth()->user()->can("appointment-create")) {
return response("Access denied", 403);
}
$deleted = $appointment->delete();
if ($deleted) {
return response("Success");
}
return response("Error", 503);
} | Class | 2 |
function selectObjectBySql($sql) {
//$logFile = "C:\\xampp\\htdocs\\supserg\\tmp\\queryLog.txt";
//$lfh = fopen($logFile, 'a');
//fwrite($lfh, $sql . "\n");
//fclose($lfh);
$res = @mysqli_query($this->connection, $this->injectProof($sql));
if ($res == null)
return null;
return mysqli_fetch_object($res);
} | Class | 2 |
public function manage() {
expHistory::set('viewable', $this->params);
$page = new expPaginator(array(
'model'=>'order_status',
'where'=>1,
'limit'=>10,
'order'=>'rank',
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
//'columns'=>array('Name'=>'title')
));
assign_to_template(array(
'page'=>$page
));
} | Base | 1 |
public function redirect($route, $code = null)
{
/** @var Uri $uri */
$uri = $this['uri'];
//Check for code in route
$regex = '/.*(\[(30[1-7])\])$/';
preg_match($regex, $route, $matches);
if ($matches) {
$route = str_replace($matches[1], '', $matches[0]);
$code = $matches[2];
}
if ($code === null) {
$code = $this['config']->get('system.pages.redirect_default_code', 302);
}
if (isset($this['session'])) {
$this['session']->close();
}
if ($uri->isExternal($route)) {
$url = $route;
} else {
$url = rtrim($uri->rootUrl(), '/') . '/';
if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
$url .= trim($route, '/'); // Remove trailing slash
} else {
$url .= ltrim($route, '/'); // Support trailing slash default routes
}
}
header("Location: {$url}", true, $code);
exit();
} | 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'])));
} | Base | 1 |
public function testVeryLongHosts($host)
{
$start = microtime(true);
$request = Request::create('/');
$request->headers->set('host', $host);
$this->assertEquals($host, $request->getHost());
$this->assertLessThan(3, microtime(true) - $start);
} | Base | 1 |
public function testAuthCheckDecryptPassword()
{
$GLOBALS['cfg']['Server']['auth_swekey_config'] = 'testConfigSwekey';
$GLOBALS['server'] = 1;
$_REQUEST['old_usr'] = '';
$_REQUEST['pma_username'] = '';
$_COOKIE['pmaServer-1'] = 'pmaServ1';
$_COOKIE['pmaUser-1'] = 'pmaUser1';
$_COOKIE['pmaPass-1'] = 'pmaPass1';
$_COOKIE['pma_iv-1'] = base64_encode('testiv09testiv09');
$GLOBALS['cfg']['blowfish_secret'] = 'secret';
$_SESSION['last_valid_captcha'] = true;
$_SESSION['last_access_time'] = time() - 1000;
$GLOBALS['cfg']['LoginCookieValidity'] = 1440;
// mock for blowfish function
$this->object = $this->getMockBuilder('AuthenticationCookie')
->disableOriginalConstructor()
->setMethods(array('cookieDecrypt'))
->getMock();
$this->object->expects($this->at(1))
->method('cookieDecrypt')
->will($this->returnValue("\xff(blank)"));
$this->assertTrue(
$this->object->authCheck()
);
$this->assertTrue(
$GLOBALS['from_cookie']
);
$this->assertEquals(
'',
$GLOBALS['PHP_AUTH_PW']
);
} | Class | 2 |
public static function versionCheck() {
$v = trim(self::latestVersion());
// print_r($v);
if ($v > self::$version) {
Hooks::attach("admin_page_notif_action", array('System', 'versionReport'));
}
}
| Base | 1 |
protected function _joinPath($dir, $name) {
$sql = 'SELECT id FROM '.$this->tbf.' WHERE parent_id="'.$dir.'" AND name="'.$this->db->real_escape_string($name).'"';
if (($res = $this->query($sql)) && ($r = $res->fetch_assoc())) {
$this->updateCache($r['id'], $this->_stat($r['id']));
return $r['id'];
}
return -1;
} | 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 |
private function getSwimlane()
{
$swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));
if (empty($swimlane)) {
throw new PageNotFoundException();
}
return $swimlane;
} | Base | 1 |
function update_license_status() {
$status = '';
$license_key = $this->get_license_key();
if (!empty($license_key) || defined('W3TC_LICENSE_CHECK')) {
$license = edd_w3edge_w3tc_check_license($license_key, W3TC_VERSION);
$version = '';
if ($license) {
$status = $license->license;
if ('host_valid' == $status) {
$version = 'pro';
} elseif (in_array($status, array('site_inactive','valid')) && w3tc_is_pro_dev_mode()) {
$status = 'valid';
$version = 'pro_dev';
}
}
$this->_config->set('plugin.type', $version);
} else {
$status = 'no_key';
$this->_config->set('plugin.type', '');
}
try {
$this->_config->save();
} catch(Exception $ex) {}
return $status;
} | Compound | 4 |
function load_gallery($auc_id)
{
$UPLOADED_PICTURES = array();
if (is_dir(UPLOAD_PATH . $auc_id)) {
if ($dir = opendir(UPLOAD_PATH . $auc_id)) {
while ($file = @readdir($dir)) {
if ($file != '.' && $file != '..' && strpos($file, 'thumb-') === false) {
$UPLOADED_PICTURES[] = UPLOAD_FOLDER . $auc_id . '/' . $file;
}
}
closedir($dir);
}
}
return $UPLOADED_PICTURES;
} | Base | 1 |
function addDiscountToCart() {
// global $user, $order;
global $order;
//lookup discount to see if it's real and valid, and not already in our cart
//this will change once we allow more than one coupon code
$discount = new discounts();
$discount = $discount->getCouponByName($this->params['coupon_code']);
if (empty($discount)) {
flash('error', gt("This discount code you entered does not exist."));
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
}
//check to see if it's in our cart already
if ($this->isDiscountInCart($discount->id)) {
flash('error', gt("This discount code is already in your cart."));
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
}
//this should really be reworked, as it shoudn't redirect directly and not return
$validateDiscountMessage = $discount->validateDiscount();
if ($validateDiscountMessage == "") {
//if all good, add to cart, otherwise it will have redirected
$od = new order_discounts();
$od->orders_id = $order->id;
$od->discounts_id = $discount->id;
$od->coupon_code = $discount->coupon_code;
$od->title = $discount->title;
$od->body = $discount->body;
$od->save();
// set this to just the discount applied via this coupon?? if so, when though? $od->discount_total = ??;
flash('message', gt("The discount code has been applied to your cart."));
} else {
flash('error', $validateDiscountMessage);
}
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
} | Class | 2 |
public function backup($type='json')
{
global $DB;
global $website;
$out = array();
$DB->query('SELECT * FROM nv_webuser_votes WHERE website = '.protect($website->id), 'object');
if($type='json')
$out = json_encode($DB->result());
return $out;
}
| Base | 1 |
public function search() {
// global $db, $user;
global $db;
$sql = "select DISTINCT(a.id) as id, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email ";
$sql .= "from " . $db->prefix . "addresses as a "; //R JOIN " .
//$db->prefix . "billingmethods as bm ON bm.addresses_id=a.id ";
$sql .= " WHERE match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] .
"*' IN BOOLEAN MODE) ";
$sql .= "order by match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) ASC LIMIT 12";
$res = $db->selectObjectsBySql($sql);
foreach ($res as $key=>$record) {
$res[$key]->title = $record->firstname . ' ' . $record->lastname;
}
//eDebug($sql);
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Base | 1 |
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 |
public static function filter() {
//print_r(self::$hooks[$var]);
$hooks = self::$hooks;
$num_args = func_num_args();
$args = func_get_args();
// print_r($args);
// if($num_args < 2)
// trigger_error("Insufficient arguments", E_USER_ERROR);
// Hook name should always be first argument
$hook_name = array_shift($args);
if(!isset($hooks[$hook_name]))
return; // No plugins have registered this hook
// print_r($args[0]);
// $args = (is_array($args))?$args[0]: $args;
if (is_array($hooks[$hook_name])) {
foreach($hooks[$hook_name] as $func){
if ($func != '') {
// $args = call_user_func_array($func, $args); //
$args = $func((array)$args);
}else{
$args = $args;
}
}
$args = $args;
}else{
$args = $args;
}
$args = is_array($args)? $args[0]: $args;
return $args;
}
| 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();
}
}
| Class | 2 |
public function Hello($host = '') {
$this->error = null; // so no confusion is caused
if(!$this->connected()) {
$this->error = array(
"error" => "Called Hello() without being connected");
return false;
}
// if hostname for HELO was not specified send default
if(empty($host)) {
// determine appropriate default to send to server
$host = "localhost";
}
// Send extended hello first (RFC 2821)
if(!$this->SendHello("EHLO", $host)) {
if(!$this->SendHello("HELO", $host)) {
return false;
}
}
return true;
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')),
'project' => $project,
)));
} | Base | 1 |
function yourls_create_nonce( $action, $user = false ) {
if( false == $user )
$user = defined( 'YOURLS_USER' ) ? YOURLS_USER : '-1';
$tick = yourls_tick();
$nonce = substr( yourls_salt($tick . $action . $user), 0, 10 );
// Allow plugins to alter the nonce
return yourls_apply_filter( 'create_nonce', $nonce, $action, $user );
} | Compound | 4 |
public static function header($vars=""){
header("Cache-Control: must-revalidate,max-age=300,s-maxage=900");
$offset = 60 * 60 * 24 * 3;
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
header($ExpStr);
header("Content-Type: text/html; charset=utf-8");
if (isset($vars)) {
# code...
$GLOBALS['data'] = $vars;
self::theme('header', $vars);
}else{
self::theme('header');
}
}
| 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 |
function update() {
global $db, $user;
$this->params['id'] = $db->selectValue('content_expRatings','expratings_id',"content_id='".$this->params['content_id']."' AND content_type='".$this->params['content_type']."' AND subtype='".$this->params['subtype']."' AND poster='".$user->id."'");
$msg = gt('Thank you for your rating');
$rating = new expRating($this->params);
if (!empty($rating->id)) $msg = gt('Your rating has been adjusted');
// save the rating
$rating->update($this->params);
// attach the rating to the datatype it belongs to (blog, news, etc..);
$obj = new stdClass();
$obj->content_type = $this->params['content_type'];
$obj->content_id = $this->params['content_id'];
$obj->expratings_id = $rating->id;
$obj->poster = $rating->poster;
if(isset($this->params['subtype'])) $obj->subtype = $this->params['subtype'];
$db->insertObject($obj, $rating->attachable_table);
$ar = new expAjaxReply(200,$msg);
$ar->send();
// flash('message', $msg);
// expHistory::back();
} | Base | 1 |
public function __construct() {
global $wgRequest;
$this->DB = wfGetDB( DB_REPLICA, 'dpl' );
$this->parameters = new Parameters();
$this->logger = new Logger( $this->parameters->getData( 'debug' )['default'] );
$this->tableNames = Query::getTableNames();
$this->wgRequest = $wgRequest;
} | Class | 2 |
function edit_externalalias() {
$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(),
));
}
| Class | 2 |
} elseif (!is_numeric($item) && ($item != '')) {
return false;
}
}
} else {
return false;
}
} else { | Base | 1 |
$newret = recyclebin::restoreFromRecycleBin($iLoc, $page_id);
if (!empty($newret)) $ret .= $newret . '<br>';
if ($iLoc->mod == 'container') {
$ret .= scan_container($container->internal, $page_id);
}
}
return $ret;
}
| Base | 1 |
public function testSetCallbackNonCallable()
{
$response = new StreamedResponse(null);
$response->setCallback(null);
} | Base | 1 |
public static function returnChildrenAsJSON() {
global $db;
//$nav = section::levelTemplate(intval($_REQUEST['id'], 0));
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$nav = $db->selectObjects('section', 'parent=' . $id, 'rank');
//FIXME $manage_all is moot w/ cascading perms now?
$manage_all = false;
if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) {
$manage_all = true;
}
//FIXME recode to use foreach $key=>$value
$navcount = count($nav);
for ($i = 0; $i < $navcount; $i++) {
if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) {
$nav[$i]->manage = 1;
$view = true;
} else {
$nav[$i]->manage = 0;
$view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id));
}
$nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name);
if (!$view) unset($nav[$i]);
}
$nav= array_values($nav);
// $nav[$navcount - 1]->last = true;
if (count($nav)) $nav[count($nav) - 1]->last = true;
// echo expJavascript::ajaxReply(201, '', $nav);
$ar = new expAjaxReply(201, '', $nav);
$ar->send();
}
| Base | 1 |
public function testIpAddressOfRangedTrustedProxyIsSetAsRemote()
{
$expectedSubRequest = Request::create('/');
$expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
$expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1');
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
Request::setTrustedProxies(array('1.1.1.1/24'));
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
$request = Request::create('/');
$request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
$strategy->render('/', $request);
Request::setTrustedProxies(array());
} | Class | 2 |
public function confirm()
{
$task = $this->getTask();
$comment = $this->getComment();
$this->response->html($this->template->render('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')
)));
} | Base | 1 |
static function isSearchable() { return true; }
| Class | 2 |
static function isSearchable() { return true; }
| Base | 1 |
protected function _filePutContents($path, $content) {
$res = false;
if ($local = $this->getTempFile($path)) {
if (@file_put_contents($local, $content, LOCK_EX) !== false
&& ($fp = @fopen($local, 'rb'))) {
clearstatcache();
$res = $this->_save($fp, $path, '', array());
@fclose($fp);
}
file_exists($local) && @unlink($local);
}
return $res;
} | Base | 1 |
protected function defaultExtensions()
{
return [
'jpg',
'jpeg',
'bmp',
'png',
'webp',
'gif',
'svg',
'js',
'map',
'ico',
'css',
'less',
'scss',
'ics',
'odt',
'doc',
'docx',
'ppt',
'pptx',
'pdf',
'swf',
'txt',
'xml',
'ods',
'xls',
'xlsx',
'eot',
'woff',
'woff2',
'ttf',
'flv',
'wmv',
'mp3',
'ogg',
'wav',
'avi',
'mov',
'mp4',
'mpeg',
'webm',
'mkv',
'rar',
'xml',
'zip'
];
} | Base | 1 |
$count += $db->dropTable($basename);
}
flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');
expHistory::back();
} | Base | 1 |
foreach($image->expTag as $tag) {
if (isset($used_tags[$tag->id])) {
$used_tags[$tag->id]->count++;
} else {
$exptag = new expTag($tag->id);
$used_tags[$tag->id] = $exptag;
$used_tags[$tag->id]->count = 1;
}
} | Class | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.