code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
public function save()
{
$project = $this->getProject();
$values = $this->request->getValues();
list($valid, $errors) = $this->categoryValidator->validateCreation($values);
if ($valid) {
if ($this->categoryModel->create($values) !== false) {
$this->flash->success(t('Your category have been created successfully.'));
$this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])), true);
return;
} else {
$errors = array('name' => array(t('Another category with the same name exists in this project')));
}
}
$this->create($values, $errors);
} | Base | 1 |
static public function deleteCategory($_id = 0) {
if ($_id != 0) {
$result_stmt = Database::prepare("
SELECT COUNT(`id`) as `numtickets` FROM `" . TABLE_PANEL_TICKETS . "`
WHERE `category` = :cat"
);
$result = Database::pexecute_first($result_stmt, array('cat' => $_id));
if ($result['numtickets'] == "0") {
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_TICKET_CATS . "` WHERE `id` = :id"
);
Database::pexecute($del_stmt, array('id' => $_id));
return true;
} else {
return false;
}
}
return false;
} | Class | 2 |
public function AdminObserver()
{
if($this->getPosted('go_back'))
{
$this->redirect('list', 'main', true);
}
$userid = $this->getId();
$sql = e107::getDb();
$user = e107::getUser();
$sysuser = e107::getSystemUser($userid, false);
$admin_log = e107::getAdminLog();
$mes = e107::getMessage();
if(!$user->checkAdminPerms('3'))
{
// TODO lan
$mes->addError("You don't have enough permissions to do this.", 'default', true);
// TODO lan
$lan = 'Security violation (not enough permissions) - Administrator --ADMIN_UID-- (--ADMIN_NAME--, --ADMIN_EMAIL--) tried to make --UID-- (--NAME--, --EMAIL--) system admin';
$search = array('--UID--', '--NAME--', '--EMAIL--', '--ADMIN_UID--', '--ADMIN_NAME--', '--ADMIN_EMAIL--');
$replace = array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email'), $user->getId(), $user->getName(), $user->getValue('email'));
e107::getLog()->add('USET_08', str_replace($search, $replace, $lan), E_LOG_INFORMATIVE);
$this->redirect('list', 'main', true);
}
if(!$sysuser->getId())
{
// TODO lan
$mes->addError("User not found.", 'default', true);
$this->redirect('list', 'main', true);
}
if(!$sysuser->isAdmin())
{
$sysuser->set('user_admin', 1)->save(); //"user","user_admin='1' WHERE user_id={$userid}"
$lan = str_replace(array('--UID--', '--NAME--', '--EMAIL--'), array($sysuser->getId(), $sysuser->getName(), $sysuser->getValue('email')), USRLAN_164);
e107::getLog()->add('USET_08', $lan, E_LOG_INFORMATIVE);
$mes->addSuccess($lan);
}
if($this->getPosted('update_admin')) e107::getUserPerms()->updatePerms($userid, $_POST['perms']);
}
| Compound | 4 |
public function get_view_config() {
global $template;
// set paths we will search in for the view
$paths = array(
BASE.'themes/'.DISPLAY_THEME.'/modules/common/views/file/configure',
BASE.'framework/modules/common/views/file/configure',
);
foreach ($paths as $path) {
$view = $path.'/'.$this->params['view'].'.tpl';
if (is_readable($view)) {
if (bs(true)) {
$bstrapview = $path.'/'.$this->params['view'].'.bootstrap.tpl';
if (file_exists($bstrapview)) {
$view = $bstrapview;
}
}
if (bs3(true)) {
$bstrapview = $path.'/'.$this->params['view'].'.bootstrap3.tpl';
if (file_exists($bstrapview)) {
$view = $bstrapview;
}
}
$template = new controllertemplate($this, $view);
$ar = new expAjaxReply(200, 'ok');
$ar->send();
}
}
} | Base | 1 |
$files[$key]->save();
}
// eDebug($files,true);
} | Base | 1 |
protected function assetExtensions()
{
return [
'jpg',
'jpeg',
'bmp',
'png',
'webp',
'gif',
'ico',
'css',
'js',
'woff',
'woff2',
'svg',
'ttf',
'eot',
'json',
'md',
'less',
'sass',
'scss',
'xml'
];
} | Base | 1 |
function yourls_verify_nonce( $action, $nonce = false, $user = false, $return = '' ) {
// get user
if( false == $user )
$user = defined( 'YOURLS_USER' ) ? YOURLS_USER : '-1';
// get current nonce value
if( false == $nonce && isset( $_REQUEST['nonce'] ) )
$nonce = $_REQUEST['nonce'];
// Allow plugins to short-circuit the rest of the function
$valid = yourls_apply_filter( 'verify_nonce', false, $action, $nonce, $user, $return );
if ($valid) {
return true;
}
// what nonce should be
$valid = yourls_create_nonce( $action, $user );
if( $nonce == $valid ) {
return true;
} else {
if( $return )
die( $return );
yourls_die( yourls__( 'Unauthorized action or expired link' ), yourls__( 'Error' ), 403 );
}
} | Compound | 4 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('action/remove', array(
'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')),
'available_events' => $this->eventManager->getAll(),
'available_actions' => $this->actionManager->getAvailableActions(),
'project' => $project,
'title' => t('Remove an action')
)));
} | Base | 1 |
public function getBackendRequest()
{
return $this->backendRequest;
} | Class | 2 |
public function allowedViewProfileField(self $user, $fieldNameIntern)
{
return $user->mProfileFieldsData->isVisible($fieldNameIntern, $this->hasRightEditProfile($user));
} | Base | 1 |
public function showall_tags() {
$images = $this->image->find('all');
$used_tags = array();
foreach ($images as $image) {
foreach($image->expTag as $tag) {
if (isset($used_tags[$tag->id])) {
$used_tags[$tag->id]->count++;
} else {
$exptag = new expTag($tag->id);
$used_tags[$tag->id] = $exptag;
$used_tags[$tag->id]->count = 1;
}
}
}
assign_to_template(array(
'tags'=>$used_tags
));
} | Base | 1 |
function db_case($array)
{
global $DatabaseType;
$counter = 0;
if ($DatabaseType == 'mysqli') {
$array_count = count($array);
$string = " CASE WHEN $array[0] =";
$counter++;
$arr_count = count($array);
for ($i = 1; $i < $arr_count; $i++) {
$value = $array[$i];
if ($value == "''" && substr($string, -1) == '=') {
$value = ' IS NULL';
$string = substr($string, 0, -1);
}
$string .= "$value";
if ($counter == ($array_count - 2) && $array_count % 2 == 0)
$string .= " ELSE ";
elseif ($counter == ($array_count - 1))
$string .= " END ";
elseif ($counter % 2 == 0)
$string .= " WHEN $array[0]=";
elseif ($counter % 2 == 1)
$string .= " THEN ";
$counter++;
}
}
return $string;
} | Base | 1 |
public function testCompletePurchaseCustomOptions()
{
$this->setMockHttpResponse('ExpressPurchaseSuccess.txt');
// Those values should not be used if custom token or payerid are passed
$this->getHttpRequest()->query->replace(array(
'token' => 'GET_TOKEN',
'PayerID' => 'GET_PAYERID',
));
$response = $this->gateway->completePurchase(array(
'amount' => '10.00',
'currency' => 'BYR',
'token' => 'CUSTOM_TOKEN',
'payerid' => 'CUSTOM_PAYERID'
))->send();
$httpRequests = $this->getMockedRequests();
$httpRequest = $httpRequests[0];
$queryArguments = $httpRequest->getQuery()->toArray();
$this->assertSame('CUSTOM_TOKEN', $queryArguments['TOKEN']);
$this->assertSame('CUSTOM_PAYERID', $queryArguments['PAYERID']);
} | Base | 1 |
function test_empty_comment() {
$result = $this->myxmlrpcserver->wp_newComment(
array(
1,
'administrator',
'administrator',
self::$post->ID,
array(
'content' => '',
),
)
);
$this->assertIXRError( $result );
$this->assertSame( 403, $result->code );
} | Class | 2 |
public static function exist($mod) {
$file = GX_MOD."/".$mod."/options.php";
if(file_exists($file)){
return true;
}else{
return false;
}
}
| 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;
}
| Class | 2 |
function update_vendor() {
$vendor = new vendor();
$vendor->update($this->params['vendor']);
expHistory::back();
} | Base | 1 |
public function GetJsForUpdateFields()
{
$sWizardHelperJsVar = (!is_null($this->m_aData['m_sWizHelperJsVarName'])) ? utils::Sanitize($this->m_aData['m_sWizHelperJsVarName'], utils::ENUM_SANITIZATION_FILTER_PARAMETER) : 'oWizardHelper'.$this->GetFormPrefix();
//str_replace(['(', ')', ';'], '', $this->m_aData['m_sWizHelperJsVarName']) : 'oWizardHelper'.$this->GetFormPrefix();
$sWizardHelperJson = $this->ToJSON();
return <<<JS
{$sWizardHelperJsVar}.m_oData = {$sWizardHelperJson};
{$sWizardHelperJsVar}.UpdateFields();
JS;
} | Base | 1 |
public function setLoggerChannel($channel = 'Organizr', $username = null)
{
if ($this->hasDB()) {
$setLogger = false;
if ($username) {
$username = htmlspecialchars($username);
}
if ($this->logger) {
if ($channel) {
if (strtolower($this->logger->getChannel()) !== strtolower($channel)) {
$setLogger = true;
}
}
if ($username) {
if (strtolower($this->logger->getTraceId()) !== strtolower($channel)) {
$setLogger = true;
}
}
} else {
$setLogger = true;
}
if ($setLogger) {
$channel = $channel ?: 'Organizr';
return $this->setupLogger($channel, $username);
} else {
return $this->logger;
}
}
} | Base | 1 |
public function testBodyConsistent()
{
$r = new Response(200, [], '0');
$this->assertEquals('0', (string)$r->getBody());
} | Base | 1 |
private function getSwimlane()
{
$swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));
if (empty($swimlane)) {
throw new PageNotFoundException();
}
return $swimlane;
} | Base | 1 |
private function getTaskLink()
{
$link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));
if (empty($link)) {
throw new PageNotFoundException();
}
return $link;
} | Class | 2 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Class | 2 |
protected function setUp()
{
$this->originalTrustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP);
} | Class | 2 |
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 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);
} | 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 remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->remove($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function replace_save_pre_shortcode( $shortcode_match ) {
$content = $shortcode_match[0];
$tag_index = array_search( 'geo_mashup_save_location', $shortcode_match );
if ( $tag_index !== false ) {
// There is an inline location - save the attributes
$this->inline_location = shortcode_parse_atts( stripslashes( $shortcode_match[$tag_index+1] ) );
// If lat and lng are missing, try to geocode based on address
$success = false;
if ( ( empty( $this->inline_location['lat'] ) or empty( $this->inline_location['lng'] ) ) and !empty( $this->inline_location['address'] ) ) {
$query = $this->inline_location['address'];
$this->inline_location = GeoMashupDB::blank_object_location( ARRAY_A );
$success = GeoMashupDB::geocode( $query, $this->inline_location );
if ( !$success ) {
// Delay and try again
sleep( 1 );
$success = GeoMashupDB::geocode( $query, $this->inline_location );
}
} else if ( is_numeric ( $this->inline_location['lat'] ) and is_numeric( $this->inline_location['lng'] ) ) {
// lat and lng were supplied
$success = true;
}
if ( $success ) {
// Remove the tag
$content = '';
} else {
$message = ( is_wp_error( GeoMashupDB::$geocode_error ) ? GeoMashupDB::$geocode_error->get_error_message() : __( 'Address not found - try making it less detailed', 'GeoMashup' ) );
$content = str_replace( ']', ' geocoding_error="' . $message . '"]', $content );
$this->inline_location = null;
}
}
return $content;
}
| Class | 2 |
public function getQueryGroupby()
{
$R1 = 'R1_' . $this->field->id;
$R2 = 'R2_' . $this->field->id;
return "$R2.user_id";
} | Base | 1 |
function manage() {
expHistory::set('viewable', $this->params);
// $category = new storeCategory();
// $categories = $category->getFullTree();
//
// // foreach($categories as $i=>$val){
// // if (!empty($this->values) && in_array($val->id,$this->values)) {
// // $this->tags[$i]->value = true;
// // } else {
// // $this->tags[$i]->value = false;
// // }
// // $this->tags[$i]->draggable = $this->draggable;
// // $this->tags[$i]->checkable = $this->checkable;
// // }
//
// $obj = json_encode($categories);
} | 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 setRssValues($rss)
{
$this->set('rsstitle', \App\Purifier::purifyByType((string) $rss->title, 'Text'));
$this->set('url', $rss->link);
} | Base | 1 |
$masteroption->delete();
}
// delete the mastergroup
$db->delete('optiongroup', 'optiongroup_master_id='.$mastergroup->id);
$mastergroup->delete();
expHistory::back();
} | Base | 1 |
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);
} | Base | 1 |
function selectBillingOptions() {
} | Base | 1 |
public function actionGetItems(){
$sql = 'SELECT id, name as value, subject FROM x2_bug_reports WHERE name LIKE :qterm ORDER BY name ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = $_GET['term'].'%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result); exit;
} | Base | 1 |
function process_tasks($task)
{
global $send;
/**
* First see if the doc_ID exists
* if not we need to create this
*/
$task = make_document($task);
update_taskman($task, 'created', '1');
if ($task['DOC_TYPE'] == 'Fax') {
deliver_document($task);
}
update_taskman($task, 'completed', '1');
if ($task['DOC_TYPE'] == "Fax") {
//now return any objects you need to Eye Form
$send['DOC_link'] = "<a href='".$webroot."/openemr/controller.php?document&view&patient_id=".$task['PATIENT_ID']."&doc_id=".$task['DOC_ID']."'
target='_blank' title=".xlt('Report was faxed. Click to view.').">
<i class='fa fa-file-pdf-o fa-fw'></i>
</a>";
//if we want a "resend" icon, add it here.
}
return $send;
} | Base | 1 |
public static function parseAndTrim($str, $isHTML = false) { //�Death from above�? �
//echo "1<br>"; eDebug($str);
// global $db;
$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(",","\,",$str);
$str = str_replace('\"', """, $str);
$str = str_replace('"', """, $str);
$str = str_replace("�", "¼", $str);
$str = str_replace("�", "½", $str);
$str = str_replace("�", "¾", $str);
//$str = htmlspecialchars($str);
//$str = utf8_encode($str);
// if (DB_ENGINE=='mysqli') {
// $str = @mysqli_real_escape_string($db->connection,trim(str_replace("�", "™", $str)));
// } elseif(DB_ENGINE=='mysql') {
// $str = @mysql_real_escape_string(trim(str_replace("�", "™", $str)),$db->connection);
// } else {
// $str = trim(str_replace("�", "™", $str));
// }
$str = @expString::escape(trim(str_replace("�", "™", $str)));
//echo "2<br>"; eDebug($str,die);
return $str;
} | Base | 1 |
$loc = expCore::makeLocation('navigation', '', $standalone->id);
if (expPermissions::check('manage', $loc)) return true;
}
return false;
}
| 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 testPhpSession53()
{
if (PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
$storage = $this->getStorage();
$this->assertFalse(isset($_SESSION));
$this->assertFalse($storage->getSaveHandler()->isActive());
session_start();
$this->assertTrue(isset($_SESSION));
// in PHP 5.3 we cannot reliably tell if a session has started
$this->assertFalse($storage->getSaveHandler()->isActive());
// PHP session might have started, but the storage driver has not, so false is correct here
$this->assertFalse($storage->isStarted());
$key = $storage->getMetadataBag()->getStorageKey();
$this->assertFalse(isset($_SESSION[$key]));
$storage->start();
$this->assertTrue(isset($_SESSION[$key]));
} | Base | 1 |
public function confirm() {
global $db;
// make sure we have what we need.
if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.'));
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.'));
// verify the id/key pair
$id = $db->selectValue('subscribers','id', 'id='.$this->params['id'].' AND hash="'.$this->params['key'].'"');
if (empty($id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));
// activate this users pending subscriptions
$sub = new stdClass();
$sub->enabled = 1;
$db->updateObject($sub, 'expeAlerts_subscribers', 'subscribers_id='.$id);
// find the users active subscriptions
$ealerts = expeAlerts::getBySubscriber($id);
assign_to_template(array(
'ealerts'=>$ealerts
));
} | Base | 1 |
public function getDeleteItemLink($icmsObj, $onlyUrl=false, $withimage=true, $userSide=false) {
if ($this->handler->_moduleName != 'system') {
$admin_side = $userSide ? '' : 'admin/';
$ret = $this->handler->_moduleUrl . $admin_side . $this->handler->_page
. "?op=del&" . $this->handler->keyName . "=" . $icmsObj->getVar($this->handler->keyName);
} else {
/**
* @todo: to be implemented...
*/
//$admin_side = $userSide ? '' : 'admin/';
$admin_side = '';
$ret = $this->handler->_moduleUrl . $admin_side
. 'admin.php?fct=' . $this->handler->_itemname
. "&op=del&" . $this->handler->keyName . "=" . $icmsObj->getVar($this->handler->keyName);
}
if ($onlyUrl) {
return $ret;
} elseif ($withimage) {
return "<a href='" . $ret . "'>
<img src='" . ICMS_IMAGES_SET_URL . "/actions/editdelete.png' style='vertical-align: middle;' alt='"
. _CO_ICMS_DELETE . "' title='" . _CO_ICMS_DELETE . "'/></a>";
}
return "<a href='" . $ret . "'>" . $icmsObj->getVar($this->handler->identifierName) . "</a>";
}
| Base | 1 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Base | 1 |
foreach($item as $subtype => $litem)
{
if(strpos($subtype, 'section-')===0)
{
if($litem=='<p><br _mce_bogus="1"></p>') continue; // tinymce empty contents, no need to save it
// has the text been changed since last save?
$last_litem = $DB->query_single(
'`text`',
'nv_webdictionary_history',
' node_id = '.protect($node_id).' AND
website = '.protect($website_id).' AND
lang = '.protect($lang).' AND
subtype = '.protect($subtype).' AND
node_type = '.protect($node_type).' AND
autosave = '.protect(($autosave)? '1' : '0').'
ORDER BY date_created DESC
'
);
if($last_litem != $litem)
{
$changed = true;
// autocleaning
if($autosave)
{
// remove previous autosaved elements
$DB->execute('
DELETE FROM nv_webdictionary_history
WHERE node_id = '.protect($node_id).' AND
website = '.protect($website_id).' AND
lang = '.protect($lang).' AND
subtype = '.protect($subtype).' AND
node_type = '.protect($node_type).' AND
autosave = 1 AND
date_created < '.(core_time() - 86400 * 7)
);
}
$DB->execute('
INSERT INTO nv_webdictionary_history
(id, website, node_type, node_id, subtype, lang, `text`, date_created, autosave)
VALUES
( 0, :website, :node_type, :node_id, :subtype, :lang, :text, :date_created, :autosave)
',
array(
":website" => $website_id,
":node_type" => $node_type,
":node_id" => $node_id,
":subtype" => $subtype,
":lang" => $lang,
":text" => $litem,
":date_created" => core_time(),
":autosave" => ($autosave)? '1' : '0'
)
);
}
}
| Base | 1 |
function cron_dbmanager_backup() {
global $wpdb;
$backup_options = get_option('dbmanager_options');
$backup_email = stripslashes($backup_options['backup_email']);
if(intval($backup_options['backup_period']) > 0) {
$backup = array();
$backup['date'] = current_time('timestamp');
$backup['mysqldumppath'] = $backup_options['mysqldumppath'];
$backup['mysqlpath'] = $backup_options['mysqlpath'];
$backup['path'] = $backup_options['path'];
$backup['password'] = str_replace('$', '\$', DB_PASSWORD);
$backup['host'] = DB_HOST;
$backup['port'] = '';
$backup['sock'] = '';
if(strpos(DB_HOST, ':') !== false) {
$db_host = explode(':', DB_HOST);
$backup['host'] = $db_host[0];
if(intval($db_host[1]) != 0) {
$backup['port'] = ' --port="'.intval($db_host[1]).'"';
} else {
$backup['sock'] = ' --socket="'.$db_host[1].'"';
}
}
$backup['command'] = '';
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
if(intval($backup_options['backup_gzip']) == 1) {
$backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz';
$backup['filepath'] = $backup['path'].'/'.$backup['filename'];
$backup['command'] = $brace.$backup['mysqldumppath'].$brace.' --force --host="'.$backup['host'].'" --user="'.DB_USER.'" --password="'.$backup['password'].'"'.$backup['port'].$backup['sock'].' --add-drop-table --skip-lock-tables '.DB_NAME.' | gzip > '.$brace.$backup['filepath'].$brace;
} else {
$backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
$backup['filepath'] = $backup['path'].'/'.$backup['filename'];
$backup['command'] = $brace.$backup['mysqldumppath'].$brace.' --force --host="'.$backup['host'].'" --user="'.DB_USER.'" --password="'.$backup['password'].'"'.$backup['port'].$backup['sock'].' --add-drop-table --skip-lock-tables '.DB_NAME.' > '.$brace.$backup['filepath'].$brace;
}
execute_backup($backup['command']);
if( !empty( $backup_email ) )
{
dbmanager_email_backup( $backup_email, $backup['filepath'] );
}
}
return;
} | Class | 2 |
static function isSearchable() {
return true;
}
| Class | 2 |
array_push($newgroupprivs, $type);
}
if(empty($newgroupprivs) || (count($newgroupprivs) == 1 &&
in_array("cascade", $newgroupprivs))) {
return array('status' => 'error',
'errorcode' => 53,
'errormsg' => 'Invalid or missing permissions list supplied');
}
updateUserOrGroupPrivs($groupid, $nodeid, $newgroupprivs, array(), "group");
return array('status' => 'success');
} | Class | 2 |
public function editspeed() {
global $db;
if (empty($this->params['id'])) return false;
$calcname = $db->selectValue('shippingcalculator', 'calculator_name', 'id='.$this->params['id']);
$calc = new $calcname($this->params['id']);
assign_to_template(array(
'calculator'=>$calc
));
} | Base | 1 |
public function saveNewFromLink($name, $link, $page_id)
{
$largestExistingOrder = Attachment::where('uploaded_to', '=', $page_id)->max('order');
return Attachment::forceCreate([
'name' => $name,
'path' => $link,
'external' => true,
'extension' => '',
'uploaded_to' => $page_id,
'created_by' => user()->id,
'updated_by' => user()->id,
'order' => $largestExistingOrder + 1
]);
} | Base | 1 |
public function save_change_password() {
global $user;
$isuser = ($this->params['uid'] == $user->id) ? 1 : 0;
if (!$user->isAdmin() && !$isuser) {
flash('error', gt('You do not have permissions to change this users password.'));
expHistory::back();
}
if (($isuser && empty($this->params['password'])) || (!empty($this->params['password']) && $user->password != user::encryptPassword($this->params['password']))) {
flash('error', gt('The current password you entered is not correct.'));
expHistory::returnTo('editable');
}
//eDebug($user);
$u = new user($this->params['uid']);
$ret = $u->setPassword($this->params['new_password1'], $this->params['new_password2']);
//eDebug($u, true);
if (is_string($ret)) {
flash('error', $ret);
expHistory::returnTo('editable');
} else {
$params = array();
$params['is_admin'] = !empty($u->is_admin);
$params['is_acting_admin'] = !empty($u->is_acting_admin);
$u->update($params);
}
if (!$isuser) {
flash('message', gt('The password for') . ' ' . $u->username . ' ' . gt('has been changed.'));
} else {
$user->password = $u->password;
flash('message', gt('Your password has been changed.'));
}
expHistory::back();
} | Base | 1 |
public function isAllowedFilename($filename){
$allow_array = array(
'.jpg','.jpeg','.png','.bmp','.gif','.ico','.webp',
'.mp3','.wav','.mp4',
'.mov','.webmv','.flac','.mkv',
'.zip','.tar','.gz','.tgz','.ipa','.apk','.rar','.iso',
'.pdf','.ofd','.swf','.epub','.xps',
'.doc','.docx','.wps',
'.ppt','.pptx','.xls','.xlsx','.txt','.psd','.csv',
'.cer','.ppt','.pub','.json','.css',
) ;
$ext = strtolower(substr($filename,strripos($filename,'.')) ); //获取文件扩展名(转为小写后)
if(in_array( $ext , $allow_array ) ){
return true ;
}
return false;
} | Base | 1 |
public function attachLink(Request $request)
{
$pageId = $request->get('attachment_link_uploaded_to');
try {
$this->validate($request, [
'attachment_link_uploaded_to' => 'required|integer|exists:pages,id',
'attachment_link_name' => 'required|string|min:1|max:255',
'attachment_link_url' => 'required|string|min:1|max:255'
]);
} catch (ValidationException $exception) {
return response()->view('attachments.manager-link-form', array_merge($request->only(['attachment_link_name', 'attachment_link_url']), [
'pageId' => $pageId,
'errors' => new MessageBag($exception->errors()),
]), 422);
}
$page = $this->pageRepo->getById($pageId);
$this->checkPermission('attachment-create-all');
$this->checkOwnablePermission('page-update', $page);
$attachmentName = $request->get('attachment_link_name');
$link = $request->get('attachment_link_url');
$attachment = $this->attachmentService->saveNewFromLink($attachmentName, $link, $pageId);
return view('attachments.manager-link-form', [
'pageId' => $pageId,
]);
} | Base | 1 |
$section = new section(intval($page));
if ($section) {
// self::deleteLevel($section->id);
$section->delete();
}
}
}
| Base | 1 |
public static function existParam($param, $post_id) {
$sql = "SELECT * FROM `posts_param` WHERE `post_id` = '{$post_id}' AND `param` = '{$param}' LIMIT 1";
$q = Db::result($sql);
if (Db::$num_rows > 0) {
return true;
}else{
return false;
}
}
| Base | 1 |
function move_standalone() {
expSession::clearAllUsersSessionCache('navigation');
assign_to_template(array(
'parent' => $this->params['parent'],
));
}
| Base | 1 |
static function description() {
return gt("This module is for managing categories in your store.");
} | Class | 2 |
function searchCategory() {
return gt('Event');
}
| Class | 2 |
protected function _stat($path) {
static $statOwner;
if (is_null($statOwner)) {
$statOwner = (!empty($this->options['statOwner']));
}
$stat = array();
if (!file_exists($path) && !is_link($path)) {
return $stat;
}
//Verifies the given path is the root or is inside the root. Prevents directory traveral.
if (!$this->_inpath($path, $this->root)) {
return $stat;
}
$gid = $uid = 0;
$stat['isowner'] = false;
$linkreadable = false;
if ($path != $this->root && is_link($path)) {
if (! $this->options['followSymLinks']) {
return array();
}
if (!($target = $this->readlink($path))
|| $target == $path) {
if (is_null($target)) {
$stat = array();
return $stat;
} else {
$stat['mime'] = 'symlink-broken';
$target = readlink($path);
$lstat = lstat($path);
$ostat = $this->getOwnerStat($lstat['uid'], $lstat['gid']);
$linkreadable = !empty($ostat['isowner']);
}
}
$stat['alias'] = $this->_path($target);
$stat['target'] = $target;
}
$size = sprintf('%u', @filesize($path));
$stat['ts'] = filemtime($path);
if ($statOwner) {
$fstat = stat($path);
$uid = $fstat['uid'];
$gid = $fstat['gid'];
$stat['perm'] = substr((string)decoct($fstat['mode']), -4);
$stat = array_merge($stat, $this->getOwnerStat($uid, $gid));
}
$dir = is_dir($path);
if (!isset($stat['mime'])) {
$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
}
//logical rights first
$stat['read'] = ($linkreadable || is_readable($path))? null : false;
$stat['write'] = is_writable($path)? null : false;
if (is_null($stat['read'])) {
$stat['size'] = $dir ? 0 : $size;
}
return $stat;
} | Base | 1 |
public function actionGetLists() {
if (!Yii::app()->user->checkAccess('ContactsAdminAccess')) {
$condition = ' AND (visibility="1" OR assignedTo="Anyone" OR assignedTo="' . Yii::app()->user->getName() . '"';
/* x2temp */
$groupLinks = Yii::app()->db->createCommand()->select('groupId')->from('x2_group_to_user')->where('userId=' . Yii::app()->user->getId())->queryColumn();
if (!empty($groupLinks))
$condition .= ' OR assignedTo IN (' . implode(',', $groupLinks) . ')';
$condition .= ' OR (visibility=2 AND assignedTo IN
(SELECT username FROM x2_group_to_user WHERE groupId IN
(SELECT groupId FROM x2_group_to_user WHERE userId=' . Yii::app()->user->getId() . '))))';
} else {
$condition = '';
}
// Optional search parameter for autocomplete
$qterm = isset($_GET['term']) ? $_GET['term'] . '%' : '';
$result = Yii::app()->db->createCommand()
->select('id,name as value')
->from('x2_lists')
->where('modelName="Contacts" AND type!="campaign" AND name LIKE :qterm' . $condition, array(':qterm' => $qterm))
->order('name ASC')
->queryAll();
echo CJSON::encode($result);
} | 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 confirm()
{
$project = $this->getProject();
$category = $this->getCategory();
$this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
)));
} | Class | 2 |
foreach ($nodes as $node) {
if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {
if ($node->active == 1) {
$text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;
} else {
$text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';
}
$ar[$node->id] = $text;
foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {
$ar[$id] = $text;
}
}
}
| Class | 2 |
protected function getRootStatExtra() {
$stat = array();
if ($this->rootName) {
$stat['name'] = $this->rootName;
}
if (! empty($this->options['icon'])) {
$stat['icon'] = $this->options['icon'];
}
if (! empty($this->options['rootCssClass'])) {
$stat['csscls'] = $this->options['rootCssClass'];
}
if (! empty($this->tmbURL)) {
$stat['tmbUrl'] = $this->tmbURL;
}
$stat['uiCmdMap'] = (isset($this->options['uiCmdMap']) && is_array($this->options['uiCmdMap']))? $this->options['uiCmdMap'] : array();
$stat['disabled'] = $this->disabled;
if (isset($this->options['netkey'])) {
$stat['netkey'] = $this->options['netkey'];
}
return $stat;
} | Base | 1 |
function columnUpdate($table, $col, $val, $where=1) {
$res = @mysqli_query($this->connection, "UPDATE `" . $this->prefix . "$table` SET `$col`='" . $val . "' WHERE $where");
/*if ($res == null)
return array();
$objects = array();
for ($i = 0; $i < mysqli_num_rows($res); $i++)
$objects[] = mysqli_fetch_object($res);*/
//return $objects;
} | Class | 2 |
$masteroption->delete();
}
// delete the mastergroup
$db->delete('optiongroup', 'optiongroup_master_id='.$mastergroup->id);
$mastergroup->delete();
expHistory::back();
} | Base | 1 |
echo '<LANGUAGE>' . htmlentities($value_arr['LANGUAGE']) . '</LANGUAGE>';
foreach ($value_arr['ENROLLMENT_INFO'] as $eid => $ed) {
echo '<ENROLLMENT_INFO_' . htmlentities($eid) . '>';
echo '<SCHOOL_ID>' . htmlentities($ed['SCHOOL_ID']) . '</SCHOOL_ID>';
echo '<CALENDAR>' . htmlentities($ed['CALENDAR']) . '</CALENDAR>';
echo '<GRADE>' . htmlentities($ed['GRADE']) . '</GRADE>';
echo '<SECTION>' . htmlentities($ed['SECTION']) . '</SECTION>';
echo '<START_DATE>' . htmlentities($ed['START_DATE']) . '</START_DATE>';
echo '<DROP_DATE>' . htmlentities($ed['DROP_DATE']) . '</DROP_DATE>';
echo '<ENROLLMENT_CODE>' . htmlentities($ed['ENROLLMENT_CODE']) . '</ENROLLMENT_CODE>';
echo '<DROP_CODE>' . htmlentities($ed['DROP_CODE']) . '</DROP_CODE>';
echo '</ENROLLMENT_INFO_' . htmlentities($eid) . '>';
}
echo '</STUDENT>';
}
echo '</SCHOOL>';
} | Base | 1 |
public function executeQuery()
{
if ($this->query !== null) {
$this->query
->offset($this->offset)
->limit($this->limit)
->orderBy($this->order, $this->direction);
if ($this->formatter !== null) {
return $this->formatter->withQuery($this->query)->format();
} else {
return $this->query->findAll();
}
}
return array();
} | Base | 1 |
public function execute(&$params) {
$options = $this->config['options'];
$action = new Actions;
$action->subject = $this->parseOption('subject',$params);
$action->dueDate = $this->parseOption('dueDate',$params);
$action->actionDescription = $this->parseOption('description',$params);
$action->priority = $this->parseOption('priority',$params);
$action->visibility = $this->parseOption('visibility',$params);
if(isset($params['model']))
$action->assignedTo = $this->parseOption('assignedTo',$params);
// if(isset($this->config['attributes']))
// $this->setModelAttributes($action,$this->config['attributes'],$params);
if ($action->save()) {
return array (
true,
Yii::t('studio', "View created action: ").$action->getLink ());
} else {
return array(false, array_shift($action->getErrors()));
}
// if($this->parseOption('reminder',$params)) {
// $notif=new Notification;
// $notif->modelType='Actions';
// $notif->createdBy=Yii::app()->user->getName();
// $notif->modelId=$model->id;
// if($_POST['notificationUsers']=='me'){
// $notif->user=Yii::app()->user->getName();
// }else{
// $notif->user=$model->assignedTo;
// }
// $notif->createDate=$model->dueDate-($_POST['notificationTime']*60);
// $notif->type='action_reminder';
// $notif->save();
// if($_POST['notificationUsers']=='both' && Yii::app()->user->getName()!=$model->assignedTo){
// $notif2=new Notification;
// $notif2->modelType='Actions';
// $notif2->createdBy=Yii::app()->user->getName();
// $notif2->modelId=$model->id;
// $notif2->user=Yii::app()->user->getName();
// $notif2->createDate=$model->dueDate-($_POST['notificationTime']*60);
// $notif2->type='action_reminder';
// $notif2->save();
// }
// }
} | Class | 2 |
function edit() {
global $template;
parent::edit();
$allforms = array();
$allforms[""] = gt('Disallow Feedback');
// calculate which event date is the one being edited
$event_key = 0;
foreach ($template->tpl->tpl_vars['record']->value->eventdate as $key=>$d) {
if ($d->id == $this->params['date_id']) $event_key = $key;
}
assign_to_template(array(
'allforms' => array_merge($allforms, expTemplate::buildNameList("forms", "event/email", "tpl", "[!_]*")),
'checked_date' => !empty($this->params['date_id']) ? $this->params['date_id'] : null,
'event_key' => $event_key,
));
}
| Base | 1 |
function lockTable($table,$lockType="WRITE") {
$sql = "LOCK TABLES `" . $this->prefix . "$table` $lockType";
$res = mysqli_query($this->connection, $sql);
return $res;
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$swimlane = $this->getSwimlane();
$this->response->html($this->helper->layout->project('swimlane/remove', array(
'project' => $project,
'swimlane' => $swimlane,
)));
} | Base | 1 |
private function getOutput() {
//@TODO: 2015-08-28 Consider calling $this->replaceVariables() here. Might cause issues with text returned in the results.
return $this->output;
} | Class | 2 |
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 |
private function load($id)
{
try {
$select = $this->zdb->select(self::TABLE);
$select->limit(1)->where(self::PK . ' = ' . $id);
if ($this->login->isSuperAdmin()) {
$select->where(Adherent::PK . ' IS NULL');
} else {
$select->where(Adherent::PK . ' = ' . (int)$this->login->id);
}
$results = $this->zdb->execute($select);
$res = $results->current();
$this->loadFromRs($res);
} catch (Throwable $e) { | Base | 1 |
public static function find($type, $property, $value)
{
global $DB;
global $website;
$DB->query('
SELECT * FROM nv_properties_items
WHERE website = '.protect($website->id).'
AND property_id = '.protect($property).'
AND value = '.protect($value),
'object');
return $DB->result();
}
| 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 |
$count += $db->dropTable($basename);
}
flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');
expHistory::back();
} | Base | 1 |
public static function cat($vars) {
switch (SMART_URL) {
case true:
# code...
$url = Options::get('siteurl')."/".$vars."/".Typo::slugify(Categories::name($vars));
break;
default:
# code...
$url = Options::get('siteurl')."/index.php?cat={$vars}";
break;
}
return $url;
} | Base | 1 |
public function withAddedHeader($header, $value)
{
if (!$this->hasHeader($header)) {
return $this->withHeader($header, $value);
}
$new = clone $this;
$new->headers[strtolower($header)][] = $value;
$new->headerLines[$header][] = $value;
return $new;
} | Base | 1 |
$emails[$u->email] = trim(user::getUserAttribution($u->id));
}
| Base | 1 |
public function show()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask_converter/show', array(
'subtask' => $subtask,
'task' => $task,
)));
} | Base | 1 |
public static function parseAndTrim($str, $isHTML = false) { //�Death from above�? �
//echo "1<br>"; eDebug($str);
// global $db;
$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(",","\,",$str);
$str = str_replace('\"', """, $str);
$str = str_replace('"', """, $str);
$str = str_replace("�", "¼", $str);
$str = str_replace("�", "½", $str);
$str = str_replace("�", "¾", $str);
//$str = htmlspecialchars($str);
//$str = utf8_encode($str);
// if (DB_ENGINE=='mysqli') {
// $str = @mysqli_real_escape_string($db->connection,trim(str_replace("�", "™", $str)));
// } elseif(DB_ENGINE=='mysql') {
// $str = @mysql_real_escape_string(trim(str_replace("�", "™", $str)),$db->connection);
// } else {
// $str = trim(str_replace("�", "™", $str));
// }
$str = @expString::escape(trim(str_replace("�", "™", $str)));
//echo "2<br>"; eDebug($str,die);
return $str;
} | 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 |
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 |
$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);
}
}
}
| Class | 2 |
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 _makeChooseCheckbox($value, $title) {
// return '<INPUT type=checkbox name=st_arr[] value=' . $value . ' checked>';
global $THIS_RET;
return "<input name=unused[$THIS_RET[STUDENT_ID]] value=" . $THIS_RET[STUDENT_ID] . " type='checkbox' id=$THIS_RET[STUDENT_ID] onClick='setHiddenCheckboxStudents(\"st_arr[]\",this,$THIS_RET[STUDENT_ID]);' />";
} | Base | 1 |
public static function recent_items($limit=5)
{
global $DB;
global $user;
global $website;
// last month only!
$DB->query('
SELECT DISTINCT nvul.website, nvul.function, nvul.item, nvul.item_title,
nvf.lid as function_title, nvf.icon as function_icon, nvul.date
FROM nv_users_log nvul,
nv_functions nvf
WHERE nvul.user = '.protect($user->id).'
AND nvul.function = nvf.id
AND nvul.item > 0
AND nvul.action = "load"
AND nvul.website = '.protect($website->id).'
AND nvul.item_title <> ""
AND nvul.date > '.( core_time() - 30 * 86400).'
AND nvul.date = ( SELECT MAX(nvulm.date)
FROM nv_users_log nvulm
WHERE nvulm.function = nvul.function
AND nvulm.item = nvul.item
AND nvulm.item_title = nvul.item_title
AND nvulm.website = '.protect($website->id).'
AND nvulm.user = '.protect($user->id).'
)
ORDER BY nvul.date DESC
LIMIT '.$limit
);
| 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);
} | Base | 1 |
recyclebin::sendToRecycleBin($loc, $parent);
//FIXME if we delete the module & sectionref the module completely disappears
// if (class_exists($secref->module)) {
// $modclass = $secref->module;
// //FIXME: more module/controller glue code
// if (expModules::controllerExists($modclass)) {
// $modclass = expModules::getControllerClassName($modclass);
// $mod = new $modclass($loc->src);
// $mod->delete_instance();
// } else {
// $mod = new $modclass();
// $mod->deleteIn($loc);
// }
// }
}
// $db->delete('sectionref', 'section=' . $parent);
$db->delete('section', 'parent=' . $parent);
}
| Class | 2 |
public function update_discount() {
$id = empty($this->params['id']) ? null : $this->params['id'];
$discount = new discounts($id);
// find required shipping method if needed
if ($this->params['required_shipping_calculator_id'] > 0) {
$this->params['required_shipping_method'] = $this->params['required_shipping_methods'][$this->params['required_shipping_calculator_id']];
} else {
$this->params['required_shipping_calculator_id'] = 0;
}
$discount->update($this->params);
expHistory::back();
} | Base | 1 |
public function getDisplayName ($plural=true) {
$moduleName = X2Model::getModuleName (get_class ($this));
return Modules::displayName ($plural, $moduleName);
} | Class | 2 |
protected function doDBUpdates() {
$title = Title::newFromText( 'Template:Extension DPL' );
// Make sure template does not already exist
if ( !$title->exists() ) {
$wikipage = WikiPage::factory( $title );
$updater = $wikipage->newPageUpdater( User::newSystemUser( 'DynamicPageList3 extension' ) );
$content = $wikipage->getContentHandler()->makeContent( '<noinclude>This page was automatically created. It serves as an anchor page for all \'\'\'[[Special:WhatLinksHere/Template:Extension_DPL|invocations]]\'\'\' of [https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:DynamicPageList3 Extension:DynamicPageList3].</noinclude>', $title );
$updater->setContent( SlotRecord::MAIN, $content );
$comment = CommentStoreComment::newUnsavedComment( 'Autogenerated DPL\'s necessary template for content inclusion' );
$updater->saveRevision(
$comment,
EDIT_NEW | EDIT_FORCE_BOT
);
}
return true;
} | Class | 2 |
foreach ($allusers as $uid) {
$u = user::getUserById($uid);
expPermissions::grant($u, 'manage', $sloc);
}
| Base | 1 |
function showByModel() {
global $order, $template, $db;
expHistory::set('viewable', $this->params);
$product = new product();
$model = $product->find("first", 'model="' . $this->params['model'] . '"');
//eDebug($model);
$product_type = new $model->product_type($model->id);
//eDebug($product_type);
$tpl = $product_type->getForm('show');
if (!empty($tpl)) $template = new controllertemplate($this, $tpl);
//eDebug($template);
$this->grabConfig(); // grab the global config
assign_to_template(array(
'config' => $this->config,
'product' => $product_type,
'last_category' => $order->lastcat
));
} | Class | 2 |
function getResourceGroups($type="") {
$return = array();
$query = "SELECT g.id AS id, "
. "g.name AS name, "
. "t.name AS type, "
. "g.ownerusergroupid AS ownerid, "
. "CONCAT(u.name, '@', a.name) AS owner "
. "FROM resourcegroup g, "
. "resourcetype t, "
. "usergroup u, "
. "affiliation a "
. "WHERE g.resourcetypeid = t.id AND "
. "g.ownerusergroupid = u.id AND "
. "u.affiliationid = a.id ";
if(! empty($type))
$query .= "AND t.name = '$type' ";
$query .= "ORDER BY t.name, g.name";
$qh = doQuery($query, 281);
while($row = mysql_fetch_assoc($qh)) {
if(empty($type))
$return[$row["id"]]["name"] = $row["type"] . "/" . $row["name"];
else
$return[$row["id"]]["name"] = $row["name"];
$return[$row["id"]]["ownerid"] = $row["ownerid"];
$return[$row["id"]]["owner"] = $row["owner"];
}
return $return;
} | Class | 2 |
public function validateRequest(App\Request $request)
{
$request->validateReadAccess();
} | Compound | 4 |
foreach ($allusers as $uid) {
$u = user::getUserById($uid);
expPermissions::grant($u, 'manage', $sloc);
}
| 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.