code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
private function _addauthor( $option ) {
//Addauthor can not be used with addlasteditor.
if ( !isset( $this->parametersProcessed['addlasteditor'] ) || !$this->parametersProcessed['addlasteditor'] ) {
$this->addTable( 'revision_actor_temp', 'rev' );
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
'rev.revactor_timestamp = (SELECT MIN(rev_aux_min.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_min WHERE rev_aux_min.revactor_page = rev.revactor_page)'
]
);
$this->_adduser( null, 'rev' );
}
} | 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;
} | Base | 1 |
self::ajax($v);
} else {
if (in_array($k, $arr)) {
self::incFront($k, $var);
} else {
self::error('404');
}
}
}
}
| Base | 1 |
public function clear($id)
{
if ($this->securityController->isWikiHibernated()) {
throw new \Exception(_t('WIKI_IN_HIBERNATION'));
}
$this->dbService->query(
'DELETE FROM' . $this->dbService->prefixTable('acls') .
'WHERE page_tag IN (SELECT tag FROM ' . $this->dbService->prefixTable('pages') .
'WHERE tag IN (SELECT resource FROM ' . $this->dbService->prefixTable('triples') .
'WHERE property="http://outils-reseaux.org/_vocabulary/type" AND value="fiche_bazar") AND body LIKE \'%"id_typeannonce":"' . $id . '"%\' );'
);
// TODO use PageManager
$this->dbService->query(
'DELETE FROM' . $this->dbService->prefixTable('pages') .
'WHERE tag IN (SELECT resource FROM ' . $this->dbService->prefixTable('triples') .
'WHERE property="http://outils-reseaux.org/_vocabulary/type" AND value="fiche_bazar") AND body LIKE \'%"id_typeannonce":"' . $id . '"%\';'
);
// TODO use TripleStore
$this->dbService->query(
'DELETE FROM' . $this->dbService->prefixTable('triples') .
'WHERE resource NOT IN (SELECT tag FROM ' . $this->dbService->prefixTable('pages') .
'WHERE 1) AND property="http://outils-reseaux.org/_vocabulary/type" AND value="fiche_bazar";'
);
} | 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 |
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 'mysqli':
$errormessage = mysqli_error($connection);
break;
}
db_show_error("", "" . _couldNotConnectToDatabase . ": $DatabaseServer", $errormessage);
}
return $connection;
} | Base | 1 |
public function fromFile($filePath)
{
if ($filePath === null) {
return;
}
$file = new FileObj($filePath);
$this->file_name = $file->getFilename();
$this->file_size = $file->getSize();
$this->content_type = $file->getMimeType();
$this->disk_name = $this->getDiskName();
$this->putFile($file->getRealPath(), $this->disk_name);
return $this;
} | Class | 2 |
public static function options($var) {
if (self::optionsExist($var)) {
include(GX_THEME.$var.'/options.php');
}
}
| Base | 1 |
$sloc = expCore::makeLocation('navigation', null, $section->id);
// remove any manage permissions for this page and it's children
// $db->delete('userpermission', "module='navigationController' AND internal=".$section->id);
// $db->delete('grouppermission', "module='navigationController' AND internal=".$section->id);
foreach ($allusers as $uid) {
$u = user::getUserById($uid);
expPermissions::grant($u, 'manage', $sloc);
}
foreach ($allgroups as $gid) {
$g = group::getGroupById($gid);
expPermissions::grantGroup($g, 'manage', $sloc);
}
}
}
| Base | 1 |
public function testAllowsForRelativeUri()
{
$uri = (new Uri)->withPath('foo');
$this->assertEquals('foo', $uri->getPath());
$this->assertEquals('foo', (string) $uri);
} | Base | 1 |
public static function canImportData() {
return true;
}
| Base | 1 |
public function __construct($exceptions = false) {
$this->exceptions = ($exceptions == true);
} | Base | 1 |
function db_properties($table)
{
global $DatabaseType, $DatabaseUsername;
switch ($DatabaseType) {
case 'mysqli':
$result = DBQuery("SHOW COLUMNS FROM $table");
while ($row = db_fetch_row($result)) {
$properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE'], strpos($row['TYPE'], '('));
if (!$pos = strpos($row['TYPE'], ','))
$pos = strpos($row['TYPE'], ')');
else
$properties[strtoupper($row['FIELD'])]['SCALE'] = substr($row['TYPE'], $pos + 1);
$properties[strtoupper($row['FIELD'])]['SIZE'] = substr($row['TYPE'], strpos($row['TYPE'], '(') + 1, $pos);
if ($row['NULL'] != '')
$properties[strtoupper($row['FIELD'])]['NULL'] = "Y";
else
$properties[strtoupper($row['FIELD'])]['NULL'] = "N";
}
break;
}
return $properties;
} | Base | 1 |
public function offset($value)
{
$this->offset = max(0, $value);
return $this;
} | Base | 1 |
public function Disconnect () {
$this->sendString('QUIT');
fclose($this->pop_conn);
} | Class | 2 |
protected function _basename($path) {
return basename($path);
} | Base | 1 |
$date->delete(); // event automatically deleted if all assoc eventdates are deleted
}
expHistory::back();
}
| 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 subscriptions() {
global $db;
expHistory::set('manageable', $this->params);
// 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
$sub = new subscribers($this->params['id']);
if (empty($sub->id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));
// get this users subscriptions
$subscriptions = $db->selectColumn('expeAlerts_subscribers', 'expeAlerts_id', 'subscribers_id='.$sub->id);
// get a list of all available E-Alerts
$ealerts = new expeAlerts();
assign_to_template(array(
'subscriber'=>$sub,
'subscriptions'=>$subscriptions,
'ealerts'=>$ealerts->find('all')
));
} | Class | 2 |
function edit_internalalias() {
$section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);
if ($section->parent == -1) {
notfoundController::handle_not_found();
exit;
} // doesn't work for standalone pages
if (empty($section->id)) {
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
}
| 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
));
} | Class | 2 |
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $r->new_version ) ),
$r->new_version
); | Compound | 4 |
public function query_single($column, $table, $where = '1=1', $order = '')
{
$rs = null;
if(!empty($order))
$order = ' ORDER BY '.$order;
try
{
$stm = $this->db->query('SELECT ' . $column . ' FROM ' . $table . ' WHERE ' . $where . $order . ' LIMIT 1');
$this->queries_count++;
$stm->setFetchMode(PDO::FETCH_NUM);
$rs = $stm->fetchAll();
$stm->closeCursor();
unset($stm);
}
catch(Exception $e)
{
return NULL;
}
if(empty($rs)) return NULL;
else return $rs[0][0];
}
| Base | 1 |
$temp_result_value = str_replace( $search, $v, $subject );
$rendered_values[] = $temp_result_value;
}
return [
implode( $delimiter, $rendered_values ),
'noparse' => false,
'isHTML' => false
];
} | Class | 2 |
$db->updateObject($value, 'section');
}
$db->updateObject($moveSec, 'section');
//handle re-ranking of previous parent
$oldSiblings = $db->selectObjects("section", "parent=" . $oldParent . " AND rank>" . $oldRank . " ORDER BY rank");
$rerank = 1;
foreach ($oldSiblings as $value) {
if ($value->id != $moveSec->id) {
$value->rank = $rerank;
$db->updateObject($value, 'section');
$rerank++;
}
}
if ($oldParent != $moveSec->parent) {
//we need to re-rank the children of the parent that the moving section has just left
$childOfLastMove = $db->selectObjects("section", "parent=" . $oldParent . " ORDER BY rank");
for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) {
$childOfLastMove[$i]->rank = $i;
$db->updateObject($childOfLastMove[$i], 'section');
}
}
}
}
self::checkForSectionalAdmins($move);
expSession::clearAllUsersSessionCache('navigation');
}
| 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 approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for note to approve'));
$lastUrl = expHistory::getLast('editable');
}
$simplenote = new expSimpleNote($this->params['id']);
assign_to_template(array(
'simplenote'=>$simplenote,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'tab'=>$this->params['tab']
));
} | Base | 1 |
public static function account_verification($email, $hash)
{
global $DB;
$status = false;
if(strpos($hash, "-") > 0)
{
list($foo, $expiry) = explode("-", $hash);
if(time() > $expiry)
{
// expired unconfirmed account!
return $status;
}
}
$DB->query('
SELECT id, activation_key
FROM nv_webusers
WHERE email = '.protect($email).'
AND activation_key = '.protect($hash).'
');
$rs = $DB->first();
if(!empty($rs->id))
{
$wu = new webuser();
$wu->load($rs->id);
// access is only enabled for blocked users (access==1) which already HAVE a password assigned
if($wu->access==1 && !empty($wu->password))
{
// account is confirmed!
if(empty($wu->email_verification_date)) // maybe the email was already verified by a previous newsletter subscription ;)
$wu->email_verification_date = time();
$wu->access = 0;
$wu->activation_key = "";
$status = $wu->save();
}
}
if(!$status)
return $status;
else
return $wu->id;
}
| Base | 1 |
public function autocomplete() {
return;
global $db;
$model = $this->params['model'];
$mod = new $model();
$srchcol = explode(",",$this->params['searchoncol']);
/*for ($i=0; $i<count($srchcol); $i++) {
if ($i>=1) $sql .= " OR ";
$sql .= $srchcol[$i].' LIKE \'%'.$this->params['query'].'%\'';
}*/
// $sql .= ' AND parent_id=0';
//eDebug($sql);
//$res = $mod->find('all',$sql,'id',25);
$sql = "select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from ".$db->prefix."product as p INNER JOIN ".$db->prefix."content_expfiles as cef ON p.id=cef.content_id INNER JOIN ".$db->prefix."expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') desc LIMIT 25";
//$res = $db->selectObjectsBySql($sql);
//$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`');
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Class | 2 |
function delete_selected() {
$item = $this->event->find('first', 'id=' . $this->params['id']);
if ($item && $item->is_recurring == 1) {
$event_remaining = false;
$eventdates = $item->eventdate[0]->find('all', 'event_id=' . $item->id);
foreach ($eventdates as $ed) {
if (array_key_exists($ed->id, $this->params['dates'])) {
$ed->delete();
} else {
$event_remaining = true;
}
}
if (!$event_remaining) {
$item->delete(); // model will also ensure we delete all event dates
}
expHistory::back();
} else {
notfoundController::handle_not_found();
}
}
| Class | 2 |
public function testConstructor()
{
$dompdf = new Dompdf();
$this->assertInstanceOf(CPDF::class, $dompdf->getCanvas());
$this->assertSame("", $dompdf->getProtocol());
$this->assertSame("", $dompdf->getBaseHost());
$this->assertSame("", $dompdf->getBasePath());
$this->assertIsArray($dompdf->getCallbacks());
$this->assertInstanceOf(Stylesheet::class, $dompdf->getCss());
$this->assertNull($dompdf->getDom());
$this->assertNull($dompdf->getHttpContext());
$this->assertInstanceOf(Options::class, $dompdf->getOptions());
$this->assertFalse($dompdf->getQuirksmode());
$this->assertNull($dompdf->getTree());
} | Base | 1 |
function updateCommandCategorieInDB(){
global $pearDB;
$DBRESULT = $pearDB->query("UPDATE `command_categories` SET `category_name` = '".$_POST["category_name"]."' , `category_alias` = '".$_POST["category_alias"]."' , `category_order` = '".$_POST["category_order"]."' WHERE `cmd_category_id` = '".$_POST["cmd_category_id"]."'");
} | Base | 1 |
public static function fixName($name) {
$name = preg_replace('/[^A-Za-z0-9\.]/','_',$name);
if ($name[0] == '.')
$name[0] = '_';
return $name;
// return preg_replace('/[^A-Za-z0-9\.]/', '-', $name);
} | Class | 2 |
public function load_by_code($code)
{
global $DB;
global $website;
if($DB->query('SELECT * FROM nv_block_groups
WHERE code = '.protect($code).'
AND website = '.$website->id))
{
$data = $DB->result();
$this->load_from_resultset($data);
}
}
| Base | 1 |
function edit_vendor() {
$vendor = new vendor();
if(isset($this->params['id'])) {
$vendor = $vendor->find('first', 'id =' .$this->params['id']);
assign_to_template(array(
'vendor'=>$vendor
));
}
} | Base | 1 |
public static function parseAndTrimExport($str, $isHTML = false) { //�Death from above�? �
//echo "1<br>"; eDebug($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("\t", " ", $str);
$str = str_replace(",", "\,", $str);
$str = str_replace("�", "¼", $str);
$str = str_replace("�", "½", $str);
$str = str_replace("�", "¾", $str);
if (!$isHTML) {
$str = str_replace('\"', """, $str);
$str = str_replace('"', """, $str);
} else {
$str = str_replace('"', '""', $str);
}
//$str = htmlspecialchars($str);
//$str = utf8_encode($str);
$str = trim(str_replace("�", "™", $str));
//echo "2<br>"; eDebug($str,die);
return $str;
} | Base | 1 |
foreach($functions as $function)
{
if($function->id == $f)
{
if($function->enabled=='1')
$sortable_assigned[] = '<li class="ui-state-highlight" value="'.$function->id.'" category="'.$function->category.'"><img src="'.NAVIGATE_URL.'/'.$function->icon.'" align="absmiddle" /> '.t($function->lid, $function->lid).'</li>';
else
$sortable_assigned[] = '<li class="ui-state-highlight ui-state-disabled" value="'.$function->id.'" category="'.$function->category.'"><img src="'.NAVIGATE_URL.'/'.$function->icon.'" align="absmiddle" /> '.t($function->lid, $function->lid).'</li>';
}
}
| Base | 1 |
public function confirm()
{
$project = $this->getProject();
$category = $this->getCategory();
$this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
)));
} | Base | 1 |
public static function post($vars) {
switch (SMART_URL) {
case true:
$inFold = (Options::v('permalink_use_index_php') == "on")? "/index.php/":"/";
if (Options::v('multilang_enable') === 'on') {
$lang = Language::isActive();
$lang = !empty($lang)? $lang . '/': '';
$url = Site::$url.$inFold. $lang .self::slug($vars)."/{$vars}";
}else{
$url = Site::$url.$inFold.self::slug($vars)."/{$vars}";
}
break;
default:
if (Options::v('multilang_enable') === 'on') {
$lang = Language::isActive();
$lang = !empty($lang)? '&lang=' . $lang: '';
$url = Site::$url."/?post={$vars}{$lang}";
}else{
$url = Site::$url."/?post={$vars}";
}
break;
}
return $url;
}
| Base | 1 |
public function delete() {
global $db;
/* 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']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
// $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
// $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
// $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('Missing id for the comment you would like to delete'));
expHistory::back();
}
// delete the comment
$comment = new expComment($this->params['id']);
$comment->delete();
// delete the association too
$db->delete($comment->attachable_table, 'expcomments_id='.$this->params['id']);
// send the user back where they came from.
expHistory::back();
} | Base | 1 |
static function description() { return gt("Places navigation links/menus on the page."); }
| 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 |
function cleanCSV($string)
{
$check = '/^[=@]/';
if (!is_numeric($string)) {
$check = '/^[=@+-]/';
}
return preg_replace($check, "", $string);
} | Base | 1 |
function edit_option_master() {
expHistory::set('editable', $this->params);
$params = isset($this->params['id']) ? $this->params['id'] : $this->params;
$record = new option_master($params);
assign_to_template(array(
'record'=>$record
));
} | Base | 1 |
private static function createUriString($scheme, $authority, $path, $query, $fragment)
{
$uri = '';
if (!empty($scheme)) {
$uri .= $scheme . ':';
}
$hierPart = '';
if (!empty($authority)) {
if (!empty($scheme)) {
$hierPart .= '//';
}
$hierPart .= $authority;
}
if ($path != null) {
// Add a leading slash if necessary.
if ($hierPart && substr($path, 0, 1) !== '/') {
$hierPart .= '/';
}
$hierPart .= $path;
}
$uri .= $hierPart;
if ($query != null) {
$uri .= '?' . $query;
}
if ($fragment != null) {
$uri .= '#' . $fragment;
}
return $uri;
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$this->response->html($this->template->render('project_tag/remove', array(
'tag' => $tag,
'project' => $project,
)));
} | Class | 2 |
$object->size = convert_size($cur->getSize());
$object->mtime = date('D, j M, Y', $cur->getMTime());
list($object->perms, $object->chmod) = $this->_getPermissions($cur->getPerms());
// Find the file type
$object->type = $this->_getFileType($cur);
// make the link depending on if it's a file or a dir
if ($cur->isDir()) {
$object->link = '<a href="' . get_url('plugin/file_manager/browse/' . $this->path . $object->name) . '">' . $object->name . '</a>';
} else {
$object->link = '<a href="' . get_url('plugin/file_manager/view/' . $this->path . $object->name . (endsWith($object->name, URL_SUFFIX) ? '?has_url_suffix=1' : '')) . '">' . $object->name . '</a>';
}
$files[$object->name] = $object;
} | Class | 2 |
public static function latestVersion () {
$check = json_decode(Options::v('system_check'), true);
$now = strtotime(date("Y-m-d H:i:s"));
if (isset($check['last_check']) ) {
$limit = $now - $check['last_check'];
if ($limit < 86400) {
$v = $check['version'];
}else{
$v = self::getLatestVersion($now);
}
}else{
$v = self::getLatestVersion($now);
}
return $v;
}
| Base | 1 |
$iloc = expUnserialize($container->internal);
if ($db->selectObject('sectionref',"module='".$iloc->mod."' AND source='".$iloc->src."'") == null) {
// There is no sectionref for this container. Populate sectionref
if ($container->external != "N;") {
$newSecRef = new stdClass();
$newSecRef->module = $iloc->mod;
$newSecRef->source = $iloc->src;
$newSecRef->internal = '';
$newSecRef->refcount = 1;
// $newSecRef->is_original = 1;
$eloc = expUnserialize($container->external);
// $section = $db->selectObject('sectionref',"module='containermodule' AND source='".$eloc->src."'");
$section = $db->selectObject('sectionref',"module='container' AND source='".$eloc->src."'");
if (!empty($section)) {
$newSecRef->section = $section->id;
$db->insertObject($newSecRef,"sectionref");
$missing_sectionrefs[] = gt("Missing sectionref for container replaced").": ".$iloc->mod." - ".$iloc->src." - PageID #".$section->id;
} else {
$db->delete('container','id="'.$container->id.'"');
$missing_sectionrefs[] = gt("Cant' find the container page for container").": ".$iloc->mod." - ".$iloc->src.' - '.gt('deleted');
}
}
}
}
assign_to_template(array(
'missing_sectionrefs'=>$missing_sectionrefs,
));
} | Base | 1 |
private function _getMetaTags()
{
$retval = '<meta charset="utf-8" />';
$retval .= '<meta name="robots" content="noindex,nofollow" />';
$retval .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge">';
$retval .= '<style>html{display: none;}</style>';
return $retval;
} | Class | 2 |
function delete_vendor() {
global $db;
if (!empty($this->params['id'])){
$db->delete('vendor', 'id =' .$this->params['id']);
}
expHistory::back();
} | Class | 2 |
public function activate_address()
{
global $db, $user;
$object = new stdClass();
$object->id = $this->params['id'];
$db->setUniqueFlag($object, 'addresses', $this->params['is_what'], "user_id=" . $user->id);
flash("message", gt("Successfully updated address."));
expHistory::back();
} | Class | 2 |
public function getFolderIdentifiersInFolder($folderIdentifier, $useFilters = true, $recursive = false)
{
$filters = $useFilters == true ? $this->fileAndFolderNameFilters : [];
return $this->driver->getFoldersInFolder($folderIdentifier, 0, 0, $recursive, $filters);
} | Base | 1 |
protected function getC3Service()
{
include_once $this->targetDirs[1].'/includes/HotPath/C3.php';
return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3();
} | Base | 1 |
public static function group($id){
$usr = Db::result(
sprintf("SELECT * FROM `user` WHERE `id` = '%d' OR `userid` = '%s' LIMIT 1",
Typo::int($id),
Typo::cleanX($id)
)
);
return $usr[0]->group;
}
| Base | 1 |
function productFeed() {
// global $db;
//check query password to avoid DDOS
/*
* condition = new
* description
* id - SKU
* link
* price
* title
* brand - manufacturer
* image link - fullsized image, up to 10, comma seperated
* product type - category - "Electronics > Audio > Audio Accessories MP3 Player Accessories","Health & Beauty > Healthcare > Biometric Monitors > Pedometers"
*/
$out = '"id","condition","description","like","price","title","brand","image link","product type"' . chr(13) . chr(10);
$p = new product();
$prods = $p->find('all', 'parent_id=0 AND ');
//$prods = $db->selectObjects('product','parent_id=0 AND');
} | Base | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$category = $this->getCategory();
if ($this->categoryModel->remove($category['id'])) {
$this->flash->success(t('Category removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this category.'));
}
$this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
foreach($functions as $function)
{
if($function->id == $f)
{
if($function->enabled=='1')
$sortable_assigned[] = '<li class="ui-state-highlight" value="'.$function->id.'" category="'.$function->category.'"><img src="'.NAVIGATE_URL.'/'.$function->icon.'" align="absmiddle" /> '.t($function->lid, $function->lid).'</li>';
else
$sortable_assigned[] = '<li class="ui-state-highlight ui-state-disabled" value="'.$function->id.'" category="'.$function->category.'"><img src="'.NAVIGATE_URL.'/'.$function->icon.'" align="absmiddle" /> '.t($function->lid, $function->lid).'</li>';
}
}
| Base | 1 |
public function setBaseUri(Response $response)
{
$response->headers->set('Content-Security-Policy', 'base-uri \'self\'', false);
} | Base | 1 |
public function confirm()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask/remove', array(
'subtask' => $subtask,
'task' => $task,
)));
} | Base | 1 |
function send_feedback() {
$success = false;
if (isset($this->params['id'])) {
$ed = new eventdate($this->params['id']);
// $email_addrs = array();
if ($ed->event->feedback_email != '') {
$msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc);
$msgtemplate->assign('params', $this->params);
$msgtemplate->assign('event', $ed);
$email_addrs = explode(',', $ed->event->feedback_email);
//This is an easy way to remove duplicates
$email_addrs = array_flip(array_flip($email_addrs));
$email_addrs = array_map('trim', $email_addrs);
$mail = new expMail();
$success += $mail->quickSend(array(
"text_message" => $msgtemplate->render(),
'to' => $email_addrs,
'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS),
'subject' => $this->params['subject'],
));
}
}
if ($success) {
flashAndFlow('message', gt('Your feedback was successfully sent.'));
} else {
flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.'));
}
}
| 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 |
function manage() {
global $db;
expHistory::set('manageable', $this->params);
// $classes = array();
$dir = BASE."framework/modules/ecommerce/billingcalculators";
if (is_readable($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if (is_file("$dir/$file") && substr("$dir/$file", -4) == ".php") {
include_once("$dir/$file");
$classname = substr($file, 0, -4);
$id = $db->selectValue('billingcalculator', 'id', 'calculator_name="'.$classname.'"');
if (empty($id)) {
// $calobj = null;
$calcobj = new $classname();
if ($calcobj->isSelectable() == true) {
$obj = new billingcalculator(array(
'title'=>$calcobj->name(),
// 'user_title'=>$calcobj->title,
'body'=>$calcobj->description(),
'calculator_name'=>$classname,
'enabled'=>false));
$obj->save();
}
}
}
}
}
$bcalc = new billingcalculator();
$calculators = $bcalc->find('all');
assign_to_template(array(
'calculators'=>$calculators
));
} | Base | 1 |
function edit() {
global $user;
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['formtitle']))
{
if (empty($this->params['id']))
{
$formtitle = gt("Add New Note");
}
else
{
$formtitle = gt("Edit Note");
}
}
else
{
$formtitle = $this->params['formtitle'];
}
$id = empty($this->params['id']) ? null : $this->params['id'];
$simpleNote = new expSimpleNote($id);
//FIXME here is where we might sanitize the note before displaying/editing it
assign_to_template(array(
'simplenote'=>$simpleNote,
'user'=>$user,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'formtitle'=>$formtitle,
'content_type'=>$this->params['content_type'],
'content_id'=>$this->params['content_id'],
'tab'=>empty($this->params['tab'])?0:$this->params['tab']
));
} | Base | 1 |
public static function load() {
$op = Db::result("SELECT * FROM `options` ORDER BY `id` ASC");
if(Db::$num_rows > 0){
return $op;
}else{
return false;
}
}
| Base | 1 |
public function __construct(Database $database, $cookiePrefix = '')
{
parent::__construct($database, TBL_SESSIONS, 'ses');
// determine session id
if (array_key_exists(COOKIE_PREFIX . '_SESSION_ID', $_COOKIE)) {
$sessionId = $_COOKIE[COOKIE_PREFIX . '_SESSION_ID'];
} else {
$sessionId = session_id();
}
$this->cookieAutoLoginId = $cookiePrefix . '_AUTO_LOGIN_ID';
if (is_int($sessionId)) {
$this->readDataById($sessionId);
} else {
$this->readDataByColumns(array('ses_session_id' => $sessionId));
if ($this->newRecord) {
// if PHP session id was commited then store them in that field
$this->setValue('ses_session_id', $sessionId);
$this->setValue('ses_timestamp', DATETIME_NOW);
}
}
// check for a valid auto login
$this->refreshAutoLogin();
} | Base | 1 |
function edit_freeform() {
$section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);
if ($section->parent == -1) {
notfoundController::handle_not_found();
exit;
} // doesn't work for standalone pages
if (empty($section->id)) {
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
}
| Base | 1 |
public function upload() {
// upload the file, but don't save the record yet...
if ($this->params['resize'] != 'false') {
$maxwidth = $this->params['max_width'];
} else {
$maxwidth = null;
}
$file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);
// since most likely this function will only get hit via flash in YUI Uploader
// and since Flash can't pass cookies, we lose the knowledge of our $user
// so we're passing the user's ID in as $_POST data. We then instantiate a new $user,
// and then assign $user->id to $file->poster so we have an audit trail for the upload
if (is_object($file)) {
$resized = !empty($file->resized) ? true : false;
$user = new user($this->params['usrid']);
$file->poster = $user->id;
$file->posted = $file->last_accessed = time();
$file->save();
if (!empty($this->params['cat'])) {
$expcat = new expCat($this->params['cat']);
$params['expCat'][0] = $expcat->id;
$file->update($params);
}
// a echo so YUI Uploader is notified of the function's completion
if ($resized) {
echo gt('File resized and then saved');
} else {
echo gt('File saved');
}
} else {
echo gt('File was NOT uploaded!');
// flash('error',gt('File was not uploaded!'));
}
} | Base | 1 |
function manage() {
global $db;
expHistory::set('manageable', $this->params);
// $classes = array();
$dir = BASE."framework/modules/ecommerce/billingcalculators";
if (is_readable($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if (is_file("$dir/$file") && substr("$dir/$file", -4) == ".php") {
include_once("$dir/$file");
$classname = substr($file, 0, -4);
$id = $db->selectValue('billingcalculator', 'id', 'calculator_name="'.$classname.'"');
if (empty($id)) {
// $calobj = null;
$calcobj = new $classname();
if ($calcobj->isSelectable() == true) {
$obj = new billingcalculator(array(
'title'=>$calcobj->name(),
// 'user_title'=>$calcobj->title,
'body'=>$calcobj->description(),
'calculator_name'=>$classname,
'enabled'=>false));
$obj->save();
}
}
}
}
}
$bcalc = new billingcalculator();
$calculators = $bcalc->find('all');
assign_to_template(array(
'calculators'=>$calculators
));
} | Class | 2 |
form_end_row();
$i++;
}
html_end_box(false);
/*
print "<pre>";
if (isset($check) && is_array($check)) {
print_r($check);
}
print "</pre>";
*/
} | Base | 1 |
$sql = array(
'table' => 'menus',
'id' => Typo::int($k),
'key' => $v
);
Db::update($sql);
}
| 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;
}
} | Base | 1 |
public function addTags($tags) {
$result = false;
$addedTags = array();
foreach ((array) $tags as $tagName) {
if (empty($tagName))
continue;
if (!in_array($tagName, $this->getTags())) { // check for duplicate tag
$tag = new Tags;
$tag->tag = '#' . ltrim($tagName, '#');
$tag->itemId = $this->getOwner()->id;
$tag->type = get_class($this->getOwner());
$tag->taggedBy = Yii::app()->getSuName();
$tag->timestamp = time();
$tag->itemName = $this->getOwner()->name;
if ($tag->save()) {
$this->_tags[] = $tag->tag; // update tag cache
$addedTags[] = $tagName;
$result = true;
} else {
throw new CHttpException(422, 'Failed saving tag due to errors: ' . json_encode($tag->errors));
}
}
}
if ($this->flowTriggersEnabled)
X2Flow::trigger('RecordTagAddTrigger', array(
'model' => $this->getOwner(),
'tags' => $addedTags,
));
return $result;
} | Class | 2 |
function db_seq_nextval($seqname)
{
global $DatabaseType;
if ($DatabaseType == 'mysqli')
$seq = "fn_" . strtolower($seqname) . "()";
return $seq;
} | Base | 1 |
$payment->write();
$i++;
}
// Ugly hack to set the money amount
$this->payment->Status = 'Created';
$this->payment->setAmount($total);
// If not everything was refunded, the payment should still have the "Captured" status
if ($total > 0) {
$endStatus = 'Captured';
}
}
parent::markCompleted($endStatus, $serviceResponse, $gatewayMessage);
if ($endStatus === 'Captured') {
$this->createMessage(Message\PartiallyRefundedResponse::class, $gatewayMessage);
} else {
$this->createMessage(Message\RefundedResponse::class, $gatewayMessage);
}
ErrorHandling::safeExtend($this->payment, 'onRefunded', $serviceResponse);
} | Class | 2 |
public static function desc($vars){
if(!empty($vars)){
$desc = substr(strip_tags(htmlspecialchars_decode($vars).". ".Options::get('sitedesc')),0,150);
}else{
$desc = substr(Options::get('sitedesc'),0,150);
}
return $desc;
} | Compound | 4 |
public static function incBack($vars) {
$file = GX_PATH.'/inc/lib/Control/Backend/'.$vars.'.control.php';
if ( file_exists($file) ) {
# code...
include($file);
}else{
self::error('404');
}
}
| Base | 1 |
$event = mysqli_fetch_assoc($result);
if($queue == "active"){
$ged_command = "-drop -type $ged_type_nbr -queue $queue ";
foreach ($array_ged_packets as $key => $value) {
if($value["key"] == true){
$ged_command .= "\"".$event[$key]."\" ";
}
}
$ged_command = trim($ged_command, " ");
shell_exec($path_ged_bin." ".$ged_command);
logging("ged_update",$ged_command);
} else {
$id_list .= $id.",";
}
}
if($queue == "history"){
$id_list = trim($id_list, ",");
$ged_command = "-drop -id ".$id_list." -queue history";
shell_exec($path_ged_bin." ".$ged_command);
logging("ged_update",$ged_command);
}
} | Base | 1 |
public function uploadImage()
{
$filesCheck = array_filter($_FILES);
if (!empty($filesCheck) && $this->approvedFileExtension($_FILES['file']['name'], 'image') && strpos($_FILES['file']['type'], 'image/') !== false) {
ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = $this->root . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'userTabs' . DIRECTORY_SEPARATOR;
$this->makeDir($targetPath);
$targetFile = $targetPath . $_FILES['file']['name'];
$this->setAPIResponse(null, pathinfo($_FILES['file']['name'], PATHINFO_BASENAME) . ' has been uploaded', null);
return move_uploaded_file($tempFile, $targetFile);
}
} | Base | 1 |
public static function id($userid){
$usr = Db::result(
sprintf("SELECT * FROM `user` WHERE `userid` = '%s' LIMIT 1",
Typo::cleanX($userid)
)
);
return $usr[0]->id;
}
| Base | 1 |
$formatted = wfMessage( 'datadump-table-column-failed' )->text();
} else {
$formatted = wfMessage( 'datadump-table-column-queued' )->text();
}
break;
case 'dumps_size':
$formatted = htmlspecialchars(
$this->getLanguage()->formatSize( isset( $row->dumps_size ) ? $row->dumps_size : 0 ) );
break;
case 'dumps_delete':
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
$query = [
'action' => 'delete',
'type' => $row->dumps_type,
'dump' => $row->dumps_filename
];
$formatted = $linkRenderer->makeLink( $this->pageTitle, wfMessage( 'datadump-delete-button' )->text(), [], $query );
break;
default:
$formatted = "Unable to format $name";
break;
}
return $formatted;
} | Compound | 4 |
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_menus
SET codename = :codename, icon = :icon, lid = :lid, notes = :notes,
functions = :functions, enabled = :enabled
WHERE id = :id',
array(
'id' => $this->id,
'codename' => value_or_default($this->codename, ""),
'icon' => value_or_default($this->icon, ""),
'lid' => value_or_default($this->lid, 0),
'notes' => value_or_default($this->notes, ""),
'functions' => json_encode($this->functions),
'enabled' => value_or_default($this->enabled, 0)
)
);
if(!$ok)
throw new Exception($DB->get_last_error());
return true;
}
| Base | 1 |
public function checkLdapLogin(){
$username = 'admin';
$password = '123456';
$ldap_open = D("Options")->get("ldap_open" ) ;
$ldap_form = D("Options")->get("ldap_form" ) ;
$ldap_form = json_decode($ldap_form,1);
if (!$ldap_open) {
return ;
}
if (!$ldap_form['user_field']) {
$ldap_form['user_field'] = 'cn';
}
$ldap_conn = ldap_connect($ldap_form['host'], $ldap_form['port']);//建立与 LDAP 服务器的连接
if (!$ldap_conn) {
$this->sendError(10011,"Can't connect to LDAP server");
return ;
}
ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, $ldap_form['version']);
$rs=ldap_bind($ldap_conn, $ldap_form['bind_dn'], $ldap_form['bind_password']);//与服务器绑定 用户登录验证 成功返回1
if (!$rs) {
$this->sendError(10011,"Can't bind to LDAP server");
return ;
}
$result = ldap_search($ldap_conn,$ldap_form['base_dn'],"(cn=*)");
$data = ldap_get_entries($ldap_conn, $result);
for ($i=0; $i<$data["count"]; $i++) {
$ldap_user = $data[$i][$ldap_form['user_field']][0] ;
$dn = $data[$i]["dn"] ;
if ($ldap_user == $username) {
//如果该用户不在数据库里,则帮助其注册
$userInfo = D("User")->isExist($username) ;
if(!$userInfo){
D("User")->register($ldap_user,$ldap_user.time());
}
$rs2=ldap_bind($ldap_conn, $dn , $password);
if ($rs2) {
D("User")->updatePwd($userInfo['uid'], $password);
$this->sendResult(array());
return ;
}
}
}
$this->sendError(10011,"用户名或者密码错误");
} | Base | 1 |
public function delete() {
global $db, $history;
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('Missing id for the comment you would like to delete'));
$lastUrl = expHistory::getLast('editable');
}
// delete the note
$simplenote = new expSimpleNote($this->params['id']);
$rows = $simplenote->delete();
// delete the assocication too
$db->delete($simplenote->attachable_table, 'expsimplenote_id='.$this->params['id']);
// send the user back where they came from.
$lastUrl = expHistory::getLast('editable');
if (!empty($this->params['tab']))
{
$lastUrl .= "#".$this->params['tab'];
}
redirect_to($lastUrl);
} | Base | 1 |
static function displayname() {
return "Events";
}
| Base | 1 |
static::$functions = ['random_bytes' => false, 'openssl_random_pseudo_bytes' => false, 'mcrypt_create_iv' => false]; | Class | 2 |
public static function DragnDropReRank2() {
global $router, $db;
$id = $router->params['id'];
$page = new section($id);
$old_rank = $page->rank;
$old_parent = $page->parent;
$new_rank = $router->params['position'] + 1; // rank
$new_parent = intval($router->params['parent']);
$db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole
$db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room
$params = array();
$params['parent'] = $new_parent;
$params['rank'] = $new_rank;
$page->update($params);
self::checkForSectionalAdmins($id);
expSession::clearAllUsersSessionCache('navigation');
}
| Base | 1 |
public function generateMessageFileName()
{
$time = microtime(true);
return date('Ymd-His-', $time) . sprintf('%04d', (int) (($time - (int) $time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.eml';
} | 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 |
public function addTab($array)
{
if (!$array) {
$this->setAPIResponse('error', 'no data was sent', 422);
return null;
}
$array = $this->checkKeys($this->getTableColumnsFormatted('tabs'), $array);
$array['group_id'] = ($array['group_id']) ?? $this->getDefaultGroupId();
$array['category_id'] = ($array['category_id']) ?? $this->getDefaultCategoryId();
$array['enabled'] = ($array['enabled']) ?? 0;
$array['default'] = ($array['default']) ?? 0;
$array['type'] = ($array['type']) ?? 1;
$array['order'] = ($array['order']) ?? $this->getNextTabOrder() + 1;
if (array_key_exists('name', $array)) {
$array['name'] = htmlspecialchars($array['name']);
if ($this->isTabNameTaken($array['name'])) {
$this->setAPIResponse('error', 'Tab name: ' . $array['name'] . ' is already taken', 409);
return false;
}
} else {
$this->setAPIResponse('error', 'Tab name was not supplied', 422);
return false;
}
if (!array_key_exists('url', $array) && !array_key_exists('url_local', $array)) {
$this->setAPIResponse('error', 'Tab url or url_local was not supplied', 422);
return false;
}
if (!array_key_exists('image', $array)) {
$this->setAPIResponse('error', 'Tab image was not supplied', 422);
return false;
}
$response = [
array(
'function' => 'query',
'query' => array(
'INSERT INTO [tabs]',
$array
)
),
];
$this->setAPIResponse(null, 'Tab added');
$this->setLoggerChannel('Tab Management');
$this->logger->debug('Added Tab for [' . $array['name'] . ']');
return $this->processQueries($response);
} | Base | 1 |
self::removeLevel($kid->id);
}
}
| Class | 2 |
public static function referenceFixtures() {
return array(
'campaign' => array ('Campaign', '.CampaignMailingBehaviorTest'),
'lists' => 'X2List',
'credentials' => 'Credentials',
'users' => 'User',
'profile' => array('Profile','.marketing')
);
} | Class | 2 |
public function confirm()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$this->response->html($this->template->render('project_tag/remove', array(
'tag' => $tag,
'project' => $project,
)));
} | 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
));
} | Base | 1 |
$this->paths[substr($key, strlen('path-'))] = $value;
}
| Base | 1 |
private function _getMetaTags()
{
$retval = '<meta charset="utf-8" />';
$retval .= '<meta name="referrer" content="none" />';
$retval .= '<meta name="robots" content="noindex,nofollow" />';
$retval .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge">';
if (! $GLOBALS['cfg']['AllowThirdPartyFraming']) {
$retval .= '<style id="cfs-style">html{display: none;}</style>';
}
return $retval;
} | Class | 2 |
$logo = "<img src=\"".Options::get('siteurl').Options::get('logo')."\"
style=\"width: $width; height: $height; margin: 1px;\">";
}else{
$logo = "<span class=\"mg genixcms-logo\"></span>";
}
return $logo;
} | Base | 1 |
form_selectable_cell('<a class="linkEditMain" href="' . html_escape('automation_networks.php?action=edit&id=' . $network['id']) . '">' . $network['name'] . '</a>', $network['id']);
form_selectable_cell($network['data_collector'], $network['id']);
form_selectable_cell($sched_types[$network['sched_type']], $network['id']);
form_selectable_cell(number_format_i18n($network['total_ips']), $network['id'], '', 'text-align:right;');
form_selectable_cell($mystat, $network['id'], '', 'text-align:right;');
form_selectable_cell($progress, $network['id'], '', 'text-align:right;');
form_selectable_cell(number_format_i18n($updown['up']) . '/' . number_format_i18n($updown['snmp']), $network['id'], '', 'text-align:right;');
form_selectable_cell(number_format_i18n($network['threads']), $network['id'], '', 'text-align:right;');
form_selectable_cell(round($network['last_runtime'],2), $network['id'], '', 'text-align:right;');
form_selectable_cell($network['enabled'] == '' || $network['sched_type'] == '1' ? __('N/A'):($network['next_start'] == '0000-00-00 00:00:00' ? substr($network['start_at'],0,16):substr($network['next_start'],0,16)), $network['id'], '', 'text-align:right;');
form_selectable_cell($network['last_started'] == '0000-00-00 00:00:00' ? 'Never':substr($network['last_started'],0,16), $network['id'], '', 'text-align:right;');
form_checkbox_cell($network['name'], $network['id']);
form_end_row();
}
} else { | 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 |
function db_seq_nextval($seqname)
{
global $DatabaseType;
if ($DatabaseType == 'mysqli')
$seq = "fn_" . strtolower($seqname) . "()";
return $seq;
} | 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.