code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
foreach ($days as $value) {
$regitem[] = $value;
}
| Base | 1 |
public function saveConfig() {
if (!empty($this->params['aggregate']) || !empty($this->params['pull_rss'])) {
if ($this->params['order'] == 'rank ASC') {
expValidator::failAndReturnToForm(gt('User defined ranking is not allowed when aggregating or pull RSS data feeds.'), $this->params);
}
}
parent::saveConfig();
} | Base | 1 |
$dt = date('Y-m-d', strtotime($match));
$sql = par_rep("/'$match'/", "'$dt'", $sql);
}
}
if (substr($sql, 0, 6) == "BEGIN;") {
$array = explode(";", $sql);
foreach ($array as $value) {
if ($value != "") {
$result = $connection->query($value);
if (!$result) {
$connection->query("ROLLBACK");
die(db_show_error($sql, _dbExecuteFailed, mysql_error()));
}
}
}
} else {
$result = $connection->query($sql) or die(db_show_error($sql, _dbExecuteFailed, mysql_error()));
}
break;
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')),
'project' => $project,
)));
} | Base | 1 |
private function resolveTrustedProxy()
{
if (!$trustedProxies = Request::getTrustedProxies()) {
return '127.0.0.1';
}
$firstTrustedProxy = reset($trustedProxies);
return false !== ($i = strpos($firstTrustedProxy, '/')) ? substr($firstTrustedProxy, 0, $i) : $firstTrustedProxy;
} | Class | 2 |
public function backup($type='json')
{
global $DB;
global $website;
$DB->query('SELECT * FROM nv_payment_methods WHERE website = '.protect($website->id), 'object');
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
public function editAlt() {
global $user;
$file = new expFile($this->params['id']);
if ($user->id==$file->poster || $user->isAdmin()) {
$file->alt = $this->params['newValue'];
$file->save();
$ar = new expAjaxReply(200, gt('Your alt was updated successfully'), $file);
} else {
$ar = new expAjaxReply(300, gt("You didn't create this file, so you can't edit it."));
}
$ar->send();
echo json_encode($file); //FIXME we exit before hitting this
} | Base | 1 |
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 |
} elseif ($part != '.') {
$depath++;
} | Base | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));
$this->checkPermission($project, $filter);
if ($this->customFilterModel->remove($filter['id'])) {
$this->flash->success(t('Custom filter removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this custom filter.'));
}
$this->response->redirect($this->helper->url->to('CustomFilterController', 'index', array('project_id' => $project['id'])));
} | Class | 2 |
$this->{$callback[0]}->{$callback[1]}($objPage, $objLayout, $this);
}
}
$headBag = $this->responseContext->get(HtmlHeadBag::class);
// Set the page title and description AFTER the modules have been generated
$this->Template->mainTitle = $objPage->rootPageTitle;
$this->Template->pageTitle = htmlspecialchars($headBag->getTitle());
// Remove shy-entities (see #2709)
$this->Template->mainTitle = str_replace('[-]', '', $this->Template->mainTitle);
$this->Template->pageTitle = str_replace('[-]', '', $this->Template->pageTitle);
// Meta robots tag
$this->Template->robots = $headBag->getMetaRobots();
// Canonical
if ($objPage->enableCanonical)
{
$this->Template->canonical = $headBag->getCanonicalUriForRequest($request);
}
// Fall back to the default title tag
if (!$objLayout->titleTag)
{
$objLayout->titleTag = '{{page::pageTitle}} - {{page::rootPageTitle}}';
}
// Assign the title and description
$this->Template->title = strip_tags(System::getContainer()->get('contao.insert_tag.parser')->replaceInline($objLayout->titleTag));
$this->Template->description = htmlspecialchars($headBag->getMetaDescription());
// Body onload and body classes
$this->Template->onload = trim($objLayout->onload);
$this->Template->class = trim($objLayout->cssClass . ' ' . $objPage->cssClass);
// Execute AFTER the modules have been generated and create footer scripts first
$this->createFooterScripts($objLayout, $objPage);
$this->createHeaderScripts($objPage, $objLayout);
} | Base | 1 |
function searchName() { return gt('Webpage'); }
| Class | 2 |
Session::set(array('lang' => $lang ) );
}
| Base | 1 |
public static function getSetting( $setting ) {
return ( array_key_exists( $setting, self::$settings ) ? self::$settings[$setting] : null );
} | Class | 2 |
function reparent_standalone() {
$standalone = $this->section->find($this->params['page']);
if ($standalone) {
$standalone->parent = $this->params['parent'];
$standalone->update();
expSession::clearAllUsersSessionCache('navigation');
expHistory::back();
} else {
notfoundController::handle_not_found();
}
}
| Base | 1 |
protected function init() {
if (!($this->options['host'] || $this->options['socket'])
|| !$this->options['user']
|| !$this->options['pass']
|| !$this->options['db']
|| !$this->options['path']
|| !$this->options['files_table']) {
return false;
}
$this->db = new mysqli($this->options['host'], $this->options['user'], $this->options['pass'], $this->options['db'], $this->options['port'], $this->options['socket']);
if ($this->db->connect_error || @mysqli_connect_error()) {
return false;
}
$this->db->set_charset('utf8');
if ($res = $this->db->query('SHOW TABLES')) {
while ($row = $res->fetch_array()) {
if ($row[0] == $this->options['files_table']) {
$this->tbf = $this->options['files_table'];
break;
}
}
}
if (!$this->tbf) {
return false;
}
$this->updateCache($this->options['path'], $this->_stat($this->options['path']));
return true;
} | Base | 1 |
private function get_lines() {
$data = "";
$endtime = 0;
/* If for some reason the fp is bad, don't inf loop */
if (!is_resource($this->smtp_conn)) {
return $data;
}
stream_set_timeout($this->smtp_conn, $this->Timeout);
if ($this->Timelimit > 0) {
$endtime = time() + $this->Timelimit;
}
while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
$str = @fgets($this->smtp_conn,515);
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />');
$this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />');
}
$data .= $str;
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />');
}
// if 4th character is a space, we are done reading, break the loop
if(substr($str,3,1) == " ") { break; }
// Timed-out? Log and break
$info = stream_get_meta_data($this->smtp_conn);
if ($info['timed_out']) {
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />");
}
break;
}
// Now check if reads took too long
if ($endtime) {
if (time() > $endtime) {
if($this->do_debug >= 4) {
$this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />");
}
break;
}
}
}
return $data;
} | Base | 1 |
$banner->increaseImpressions();
}
}
// assign banner to the template and show it!
assign_to_template(array(
'banners'=>$banners
));
} | Base | 1 |
public function remove()
{
$project = $this->getProject();
$this->checkCSRFParam();
$column_id = $this->request->getIntegerParam('column_id');
if ($this->columnModel->remove($column_id)) {
$this->flash->success(t('Column removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this column.'));
}
$this->response->redirect($this->helper->url->to('ColumnController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
static function convertUTF($string) {
return $string = str_replace('?', '', htmlspecialchars($string, ENT_IGNORE, 'UTF-8'));
} | Base | 1 |
function &getAll(&$dbh, $proposalId)
{
$sql = "SELECT *, UNIX_TIMESTAMP(timestamp) AS timestamp FROM package_proposal_votes WHERE pkg_prop_id = ". $dbh->quoteSmart($proposalId) ." ORDER BY timestamp ASC";
$res = $dbh->query($sql);
if (DB::isError($res)) {
return $res;
}
$votes = array();
while ($set = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
$set['reviews'] = unserialize($set['reviews']);
$votes[$set['user_handle']] = new ppVote($set);
}
return $votes;
} | Base | 1 |
function edit_order_item() {
$oi = new orderitem($this->params['id'], true, true);
if (empty($oi->id)) {
flash('error', gt('Order item doesn\'t exist.'));
expHistory::back();
}
$oi->user_input_fields = expUnserialize($oi->user_input_fields);
$params['options'] = $oi->opts;
$params['user_input_fields'] = $oi->user_input_fields;
$oi->product = new product($oi->product->id, true, true);
if ($oi->product->parent_id != 0) {
$parProd = new product($oi->product->parent_id);
//$oi->product->optiongroup = $parProd->optiongroup;
$oi->product = $parProd;
}
//FIXME we don't use selectedOpts?
// $oi->selectedOpts = array();
// if (!empty($oi->opts)) {
// foreach ($oi->opts as $opt) {
// $option = new option($opt[0]);
// $og = new optiongroup($option->optiongroup_id);
// if (!isset($oi->selectedOpts[$og->id]) || !is_array($oi->selectedOpts[$og->id]))
// $oi->selectedOpts[$og->id] = array($option->id);
// else
// array_push($oi->selectedOpts[$og->id], $option->id);
// }
// }
//eDebug($oi->selectedOpts);
assign_to_template(array(
'oi' => $oi,
'params' => $params
));
} | 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,
)));
} | Base | 1 |
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();
} | Class | 2 |
public function createFromBill(Request $request, Bill $bill)
{
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_bill', ['name' => $bill->name]));
$this->createDefaultRuleGroup();
$this->createDefaultRule();
$preFilled = [
'strict' => true,
'title' => (string)trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
];
// make triggers and actions from the bill itself.
// get triggers and actions for bill:
$oldTriggers = $this->getTriggersForBill($bill);
$oldActions = $this->getActionsForBill($bill);
$triggerCount = \count($oldTriggers);
$actionCount = \count($oldActions);
$subTitleIcon = 'fa-clone';
// title depends on whether or not there is a rule group:
$subTitle = (string)trans('firefly.make_new_rule_no_group');
// flash old data
$request->session()->flash('preFilled', $preFilled);
// put previous url in session if not redirect from store (not "create another").
if (true !== session('rules.create.fromStore')) {
$this->rememberPreviousUri('rules.create.uri');
}
session()->forget('rules.create.fromStore');
return view(
'rules.rule.create', compact('subTitleIcon', 'oldTriggers', 'preFilled', 'oldActions', 'triggerCount', 'actionCount', 'subTitle')
);
} | Base | 1 |
public function showall() {
expHistory::set('viewable', $this->params);
// figure out if should limit the results
if (isset($this->params['limit'])) {
$limit = $this->params['limit'] == 'none' ? null : $this->params['limit'];
} else {
$limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;
}
$order = isset($this->config['order']) ? $this->config['order'] : 'publish DESC';
// pull the news posts from the database
$items = $this->news->find('all', $this->aggregateWhereClause(), $order);
// merge in any RSS news and perform the sort and limit the number of posts we return to the configured amount.
if (!empty($this->config['pull_rss'])) $items = $this->mergeRssData($items);
// setup the pagination object to paginate the news stories.
$page = new expPaginator(array(
'records'=>$items,
'limit'=>$limit,
'order'=>$order,
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'view'=>empty($this->params['view']) ? null : $this->params['view']
));
assign_to_template(array(
'page'=>$page,
'items'=>$page->records,
'rank'=>($order==='rank')?1:0,
'params'=>$this->params,
));
} | Base | 1 |
function build_daterange_sql($timestamp, $endtimestamp=null, $field='date', $multiday=false) {
if (empty($endtimestamp)) {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($timestamp) . ")";
} else {
$date_sql = "((".$field." >= " . expDateTime::startOfDayTimestamp($timestamp) . " AND ".$field." <= " . expDateTime::endOfDayTimestamp($endtimestamp) . ")";
}
if ($multiday)
$date_sql .= " OR (" . expDateTime::startOfDayTimestamp($timestamp) . " BETWEEN ".$field." AND dateFinished)";
$date_sql .= ")";
return $date_sql;
}
| Base | 1 |
private function configureDefaults(array $config)
{
$defaults = [
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
'verify' => true,
'cookies' => false
];
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set
if ($proxy = getenv('HTTP_PROXY')) {
$defaults['proxy']['http'] = $proxy;
}
if ($proxy = getenv('HTTPS_PROXY')) {
$defaults['proxy']['https'] = $proxy;
}
if ($noProxy = getenv('NO_PROXY')) {
$cleanedNoProxy = str_replace(' ', '', $noProxy);
$defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
}
$this->config = $config + $defaults;
if (!empty($config['cookies']) && $config['cookies'] === true) {
$this->config['cookies'] = new CookieJar();
}
// Add the default user-agent header.
if (!isset($this->config['headers'])) {
$this->config['headers'] = ['User-Agent' => default_user_agent()];
} else {
// Add the User-Agent header if one was not already set.
foreach (array_keys($this->config['headers']) as $name) {
if (strtolower($name) === 'user-agent') {
return;
}
}
$this->config['headers']['User-Agent'] = default_user_agent();
}
} | Base | 1 |
public function actionSeoFileLink($url, $robots = '', $canonical = '', $inline = true, $fileName = '')
{
$url = base64_decode($url);
$robots = base64_decode($robots);
$canonical = base64_decode($canonical);
$url = UrlHelper::absoluteUrlWithProtocol($url);
$contents = file_get_contents($url);
$response = Craft::$app->getResponse();
if ($contents) {
// Add the X-Robots-Tag header
if (!empty($robots)) {
$headerValue = $robots;
$response->headers->add('X-Robots-Tag', $headerValue);
}
// Add the Link header
if (!empty($canonical)) {
$headerValue = '<'.$canonical.'>; rel="canonical"';
$response->headers->add('Link', $headerValue);
}
// Ensure the file type is allowed
// ref: https://craftcms.com/docs/3.x/config/config-settings.html#allowedfileextensions
$allowedExtensions = Craft::$app->getConfig()->getGeneral()->allowedFileExtensions;
if (($ext = pathinfo($fileName, PATHINFO_EXTENSION)) !== '') {
$ext = strtolower($ext);
}
if ($ext === '' || !in_array($ext, $allowedExtensions, true)) {
throw new ServerErrorHttpException(Craft::t('seomatic', 'File format not allowed.'));
}
// Send the file as a stream, so it can exist anywhere
$response->sendContentAsFile(
$contents,
$fileName,
[
'inline' => $inline,
'mimeType' => FileHelper::getMimeTypeByExtension($fileName)
]
);
} else {
throw new NotFoundHttpException(Craft::t('seomatic', 'File not found.'));
}
return $response;
} | Base | 1 |
self::removeLevel($kid->id);
}
}
| Base | 1 |
protected function _save($fp, $dir, $name, $stat) {
$this->clearcache();
$mime = $stat['mime'];
$w = !empty($stat['width']) ? $stat['width'] : 0;
$h = !empty($stat['height']) ? $stat['height'] : 0;
$id = $this->_joinPath($dir, $name);
rewind($fp);
$stat = fstat($fp);
$size = $stat['size'];
if (($tmpfile = tempnam($this->tmpPath, $this->id))) {
if (($trgfp = fopen($tmpfile, 'wb')) == false) {
unlink($tmpfile);
} else {
while (!feof($fp)) {
fwrite($trgfp, fread($fp, 8192));
}
fclose($trgfp);
chmod($tmpfile, 0644);
$sql = $id > 0
? 'REPLACE INTO %s (id, parent_id, name, content, size, mtime, mime, width, height) VALUES ('.$id.', %d, "%s", LOAD_FILE("%s"), %d, %d, "%s", %d, %d)'
: 'INSERT INTO %s (parent_id, name, content, size, mtime, mime, width, height) VALUES (%d, "%s", LOAD_FILE("%s"), %d, %d, "%s", %d, %d)';
$sql = sprintf($sql, $this->tbf, $dir, $this->db->real_escape_string($name), $this->loadFilePath($tmpfile), $size, time(), $mime, $w, $h);
$res = $this->query($sql);
unlink($tmpfile);
if ($res) {
return $id > 0 ? $id : $this->db->insert_id;
}
}
}
$content = '';
rewind($fp);
while (!feof($fp)) {
$content .= fread($fp, 8192);
}
$sql = $id > 0
? 'REPLACE INTO %s (id, parent_id, name, content, size, mtime, mime, width, height) VALUES ('.$id.', %d, "%s", "%s", %d, %d, "%s", %d, %d)'
: 'INSERT INTO %s (parent_id, name, content, size, mtime, mime, width, height) VALUES (%d, "%s", "%s", %d, %d, "%s", %d, %d)';
$sql = sprintf($sql, $this->tbf, $dir, $this->db->real_escape_string($name), $this->db->real_escape_string($content), $size, time(), $mime, $w, $h);
unset($content);
if ($this->query($sql)) {
return $id > 0 ? $id : $this->db->insert_id;
}
return false;
} | Base | 1 |
public function getPurchaseOrderByJSON() {
if(!empty($this->params['vendor'])) {
$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);
} else {
$purchase_orders = $this->purchase_order->find('all');
}
echo json_encode($purchase_orders);
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')),
'project' => $project,
)));
} | Class | 2 |
function delete_recurring() {
$item = $this->event->find('first', 'id=' . $this->params['id']);
if ($item->is_recurring == 1) { // need to give user options
expHistory::set('editable', $this->params);
assign_to_template(array(
'checked_date' => $this->params['date_id'],
'event' => $item,
));
} else { // Process a regular delete
$item->delete();
}
}
| Class | 2 |
public static function cat($vars) {
switch (SMART_URL) {
case true:
# code...
$inFold = (Options::v('permalink_use_index_php') == "on")? "/index.php":"";
$url = Site::$url.$inFold."/category/".$vars."/".Typo::slugify(Categories::name($vars));
break;
default:
# code...
$url = Site::$url."/?cat={$vars}";
break;
}
return $url;
}
| 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 |
public function getQuerySelect()
{
return "c.submitted_by AS `" . $this->name . "`";
} | Base | 1 |
public function confirm()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask/remove', array(
'subtask' => $subtask,
'task' => $task,
)));
} | Class | 2 |
protected function _renderVarInput_number($form, &$var, &$vars)
{
$value = $var->getValue($vars);
if ($var->type->getProperty('fraction')) {
$value = sprintf('%01.' . $var->type->getProperty('fraction') . 'f', $value);
}
$linfo = Horde_Nls::getLocaleInfo();
/* Only if there is a mon_decimal_point do the
* substitution. */
if (!empty($linfo['mon_decimal_point'])) {
$value = str_replace('.', $linfo['mon_decimal_point'], $value);
}
return sprintf('<input type="text" size="5" name="%s" id="%s" value="%s"%s />',
htmlspecialchars($var->getVarName()),
$this->_genID($var->getVarName(), false),
$value,
$this->_getActionScripts($form, $var)
);
} | Base | 1 |
public function theme_switch() {
if (!expUtil::isReallyWritable(BASE.'framework/conf/config.php')) { // we can't write to the config.php file
flash('error',gt('The file /framework/conf/config.php is NOT Writeable. You will be unable to change the theme.'));
}
expSettings::change('DISPLAY_THEME_REAL', $this->params['theme']);
expSession::set('display_theme',$this->params['theme']);
$sv = isset($this->params['sv'])?$this->params['sv']:'';
if (strtolower($sv)=='default') {
$sv = '';
}
expSettings::change('THEME_STYLE_REAL',$sv);
expSession::set('theme_style',$sv);
expDatabase::install_dbtables(); // update tables to include any custom definitions in the new theme
// $message = (MINIFY != 1) ? "Exponent is now minifying Javascript and CSS" : "Exponent is no longer minifying Javascript and CSS" ;
// flash('message',$message);
$message = gt("You have selected the")." '".$this->params['theme']."' ".gt("theme");
if ($sv != '') {
$message .= ' '.gt('with').' '.$this->params['sv'].' '.gt('style variation');
}
flash('message',$message);
// expSession::un_set('framework');
expSession::set('force_less_compile', 1);
// expTheme::removeSmartyCache();
expSession::clearAllUsersSessionCache();
expHistory::returnTo('manageable');
} | Base | 1 |
protected function unserialize(string $data)
{
if (is_numeric($data)) {
return $data;
}
$unserialize = $this->options['serialize'][1] ?? "unserialize";
return $unserialize($data);
} | Base | 1 |
public function chmod() {
if (!AuthUser::hasPermission('file_manager_chmod')) {
Flash::set('error', __('You do not have sufficient permissions to change the permissions on a file or directory.'));
redirect(get_url('plugin/file_manager/browse/'));
}
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/chmod')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
}
else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('plugin/file_manager/browse/'));
}
$data = $_POST['file'];
$data['name'] = str_replace('..', '', $data['name']);
$file = FILES_DIR . '/' . $data['name'];
if (file_exists($file)) {
if (@!chmod($file, octdec($data['mode'])))
Flash::set('error', __('Permission denied!'));
}
else {
Flash::set('error', __('File or directory not found!'));
}
$path = substr($data['name'], 0, strrpos($data['name'], '/'));
redirect(get_url('plugin/file_manager/browse/' . $path));
} | Class | 2 |
public function manage_sitemap() {
global $db, $user, $sectionObj, $sections;
expHistory::set('viewable', $this->params);
$id = $sectionObj->id;
$current = null;
// all we need to do is determine the current section
$navsections = $sections;
if ($sectionObj->parent == -1) {
$current = $sectionObj;
} else {
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
}
assign_to_template(array(
'sasections' => $db->selectObjects('section', 'parent=-1'),
'sections' => $navsections,
'current' => $current,
'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),
));
}
| Class | 2 |
public function test_valid_comment_allow_empty_content() {
add_filter( 'allow_empty_comment', '__return_true' );
$result = $this->myxmlrpcserver->wp_newComment(
array(
1,
'administrator',
'administrator',
self::$post->ID,
array(
'content' => ' ',
),
)
);
$this->assertNotIXRError( $result );
} | Class | 2 |
public function testNoAuthority($input)
{
$uri = new Uri($input);
$this->assertEquals($input, (string) $uri);
} | Base | 1 |
public function params()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) {
$this->create();
return;
}
$action = $this->actionManager->getAction($values['action_name']);
$action_params = $action->getActionRequiredParameters();
if (empty($action_params)) {
$this->doCreation($project, $values + array('params' => array()));
}
$projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$project['id']]);
$this->response->html($this->template->render('action_creation/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->columnModel->getList($project['id']),
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),
'projects_list' => $projects_list,
'colors_list' => $this->colorModel->getList(),
'categories_list' => $this->categoryModel->getList($project['id']),
'links_list' => $this->linkModel->getList(0, false),
'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'swimlane_list' => $this->swimlaneModel->getList($project['id']),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | Base | 1 |
private function generateTempFileData()
{
return [
'name' => md5(mt_rand()),
'tmp_name' => tempnam(sys_get_temp_dir(), ''),
'type' => 'image/jpeg',
'size' => mt_rand(1000, 10000),
'error' => '0',
];
} | Class | 2 |
public function update()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$values = $this->request->getValues();
list($valid, $errors) = $this->tagValidator->validateModification($values);
if ($tag['project_id'] != $project['id']) {
throw new AccessForbiddenException();
}
if ($valid) {
if ($this->tagModel->update($values['id'], $values['name'])) {
$this->flash->success(t('Tag updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this tag.'));
}
$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
} else {
$this->edit($values, $errors);
}
} | Base | 1 |
public function setContainer($container, $type = 'ctText')
{
$this->container = $container;
$container->setType($type);
} | Base | 1 |
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 |
public function push($remote = NULL, array $params = NULL)
{
$this->run('push', $remote, $params);
return $this;
} | Class | 2 |
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 |
public function __construct($mongo, array $options)
{
if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
throw new \InvalidArgumentException('MongoClient or Mongo instance required');
}
if (!isset($options['database']) || !isset($options['collection'])) {
throw new \InvalidArgumentException('You must provide the "database" and "collection" option for MongoDBSessionHandler');
}
$this->mongo = $mongo;
$this->options = array_merge(array(
'id_field' => '_id',
'data_field' => 'data',
'time_field' => 'time',
'expiry_field' => 'expires_at',
), $options);
} | Base | 1 |
protected function getSubtask()
{
$subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id'));
if (empty($subtask)) {
throw new PageNotFoundException();
}
return $subtask;
} | Base | 1 |
protected function getStatusCode($exception)
{
if ($exception instanceof HttpExceptionInterface) {
$code = $exception->getStatusCode();
}
elseif ($exception instanceof AjaxException) {
$code = 406;
}
else {
$code = 500;
}
return $code;
}
| Base | 1 |
$pos = strpos($line, $match);
if ($pos !== false) {
$var = getvarname(strtok($field, '#'));
if ($var != '[]') eval('$r' . $var . '=$block;');
}
}
}
return $r;
} | Base | 1 |
foreach ($evs as $key=>$event) {
if ($condense) {
$eventid = $event->id;
$multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));
if (!empty($multiday_event)) {
unset($evs[$key]);
continue;
}
}
$evs[$key]->eventstart += $edate->date;
$evs[$key]->eventend += $edate->date;
$evs[$key]->date_id = $edate->id;
if (!empty($event->expCat)) {
$catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);
// if (substr($catcolor,0,1)=='#') $catcolor = '" style="color:'.$catcolor.';';
$evs[$key]->color = $catcolor;
}
}
| Class | 2 |
function manage_upcharge() {
$this->loc->src = "@globalstoresettings";
$config = new expConfig($this->loc);
$this->config = $config->config;
$gc = new geoCountry();
$countries = $gc->find('all');
$gr = new geoRegion();
$regions = $gr->find('all',null,'rank asc,name asc');
assign_to_template(array(
'countries'=>$countries,
'regions'=>$regions,
'upcharge'=>!empty($this->config['upcharge'])?$this->config['upcharge']:''
));
} | Class | 2 |
public function event()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id'])) {
return $this->create();
}
return $this->response->html($this->template->render('action_creation/event', array(
'values' => $values,
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | Base | 1 |
function draw_vdef_preview($vdef_id) {
?>
<tr class='even'>
<td style='padding:4px'>
<pre>vdef=<?php print get_vdef($vdef_id, true);?></pre>
</td>
</tr>
<?php
} | Base | 1 |
public static function flag($vars) {
switch (SMART_URL) {
case true:
$lang = '?lang=' . $vars;
if (isset($_GET['lang'])) {
$uri = explode('?', $_SERVER['REQUEST_URI']);
$uri = $uri[0];
}else{
$uri = $_SERVER['REQUEST_URI'];
}
$url = $uri . $lang;
break;
default:
// print_r($_GET);
if (!empty($_GET)) {
$val = '';
foreach ($_GET as $key => $value) {
if ($key == 'lang') {
$val .= '&lang='.$vars;
}else{
$val .= $key . '=' . $value;
}
}
}else{
$val = "lang=".$vars;
}
$lang = !isset($_GET['lang'])? '&lang=' . $vars: $val;
$url = Site::$url . '/?' . $lang;
break;
}
return $url;
}
| Base | 1 |
public function searchNew() {
global $db, $user;
//$this->params['query'] = str_ireplace('-','\-',$this->params['query']);
$sql = "select DISTINCT(p.id) as id, p.title, model, sef_url, f.id as fileid, ";
$sql .= "match (p.title,p.model,p.body) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) as relevance, ";
$sql .= "CASE when p.model like '" . $this->params['query'] . "%' then 1 else 0 END as modelmatch, ";
$sql .= "CASE when p.title like '%" . $this->params['query'] . "%' then 1 else 0 END as titlematch ";
$sql .= "from " . $db->prefix . "product as p INNER JOIN " .
$db->prefix . "content_expFiles as cef ON p.id=cef.content_id AND cef.content_type IN ('product','eventregistration','donation','giftcard') AND cef.subtype='mainimage' INNER JOIN " . $db->prefix .
"expFiles as f ON cef.expFiles_id = f.id WHERE ";
if (!$user->isAdmin()) $sql .= '(p.active_type=0 OR p.active_type=1) AND ';
$sql .= " match (p.title,p.model,p.body) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) AND p.parent_id=0 ";
$sql .= " HAVING relevance > 0 ";
//$sql .= "GROUP BY p.id ";
$sql .= "order by modelmatch,titlematch,relevance desc LIMIT 10";
eDebug($sql);
$res = $db->selectObjectsBySql($sql);
eDebug($res, true);
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Class | 2 |
public function update()
{
try {
$_recipients = array();
if ($this->recipients != null) {
foreach ($this->recipients as $_r) {
$_recipients[$_r->id] = $_r->sname . ' <' . $_r->email . '>';
}
}
$sender = ($this->sender === 0) ?
new Expression('NULL') : $this->sender;
$sender_name = ($this->sender_name === null) ?
new Expression('NULL') : $this->sender_name;
$sender_address = ($this->sender_address === null) ?
new Expression('NULL') : $this->sender_address;
$values = array(
'mailing_sender' => $sender,
'mailing_sender_name' => $sender_name,
'mailing_sender_address' => $sender_address,
'mailing_subject' => $this->subject,
'mailing_body' => $this->message,
'mailing_date' => $this->date,
'mailing_recipients' => serialize($_recipients),
'mailing_sent' => ($this->sent) ?
true :
($this->zdb->isPostgres() ? 'false' : 0)
);
$update = $this->zdb->update(self::TABLE);
$update->set($values);
$update->where(self::PK . ' = ' . $this->mailing->history_id);
$this->zdb->execute($update);
return true;
} catch (Throwable $e) {
Analog::log(
'An error occurend updating Mailing | ' . $e->getMessage(),
Analog::ERROR
);
throw $e;
}
} | Base | 1 |
$link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr );
} else {
$link_text = '';
}
if ( trim( $link_text ) == '' )
$link_text = $_post->post_title;
/**
* Filters a retrieved attachment page link.
*
* @since 2.7.0
*
* @param string $link_html The page link HTML output.
* @param int $id Post ID.
* @param string|array $size Size of the image. Image size or array of width and height values (in that order).
* Default 'thumbnail'.
* @param bool $permalink Whether to add permalink to image. Default false.
* @param bool $icon Whether to include an icon. Default false.
* @param string|bool $text If string, will be link text. Default false.
*/
return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
} | Base | 1 |
$this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);
} | Base | 1 |
private function getSwimlane()
{
$swimlane = $this->swimlaneModel->getById($this->request->getIntegerParam('swimlane_id'));
if (empty($swimlane)) {
throw new PageNotFoundException();
}
return $swimlane;
} | Base | 1 |
public function confirm()
{
$task = $this->getTask();
$link = $this->getTaskLink();
$this->response->html($this->template->render('task_internal_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Base | 1 |
foreach ($day as $extevent) {
$event_cache = new stdClass();
$event_cache->feed = $extgcalurl;
$event_cache->event_id = $extevent->event_id;
$event_cache->title = $extevent->title;
$event_cache->body = $extevent->body;
$event_cache->eventdate = $extevent->eventdate->date;
if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400)
$event_cache->dateFinished = $extevent->dateFinished;
if (isset($extevent->eventstart))
$event_cache->eventstart = $extevent->eventstart;
if (isset($extevent->eventend))
$event_cache->eventend = $extevent->eventend;
if (isset($extevent->is_allday))
$event_cache->is_allday = $extevent->is_allday;
$found = false;
if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries
$found = $db->selectObject('event_cache','feed="'.$extgcalurl.'" AND event_id="'.$event_cache->event_id.'" AND eventdate='.$event_cache->eventdate);
if (!$found)
$db->insertObject($event_cache,'event_cache');
}
| Class | 2 |
public static function is_email($vars){
if(isset($_GET['act']) && $_GET['act'] == 'edit'){
$id = Typo::int($_GET['id']);
$where = "AND `id` != '{$id}' ";
}else{
$where = '';
}
$vars = sprintf('%s', Typo::cleanX($vars));
$sql = sprintf("SELECT * FROM `user` WHERE `email` = '%s' %s", $vars, $where );
$e = Db::result($sql);
if(Db::$num_rows > 0){
return false;
}else{
return true;
}
}
| Base | 1 |
public static function withoutQueryValue(UriInterface $uri, $key)
{
$current = $uri->getQuery();
if (!$current) {
return $uri;
}
$result = [];
foreach (explode('&', $current) as $part) {
if (explode('=', $part)[0] !== $key) {
$result[] = $part;
};
}
return $uri->withQuery(implode('&', $result));
} | Base | 1 |
foreach ($allgroups as $gid) {
$g = group::getGroupById($gid);
expPermissions::grantGroup($g, 'manage', $sloc);
}
| 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 |
foreach ($allgroups as $gid) {
$g = group::getGroupById($gid);
expPermissions::grantGroup($g, 'manage', $sloc);
}
| Base | 1 |
function fix_serialized_columns()
{
global $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT id_action, extra
FROM {db_prefix}log_actions
WHERE action IN ({string:remove}, {string:delete})',
array(
'remove' => 'remove',
'delete' => 'delete',
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (@unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1)
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_actions
SET extra = {string:extra}
WHERE id_action = {int:current_action}',
array(
'current_action' => $row['id_action'],
'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4],
)
);
}
$smcFunc['db_free_result']($request);
// Refresh some cached data.
updateSettings(array(
'memberlist_updated' => time(),
));
} | 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 |
foreach($fields as $field)
{
if(substr($key, 0, strlen($field.'-'))==$field.'-')
{
$this->dictionary[substr($key, strlen($field.'-'))][$field] = $value;
}
}
| Base | 1 |
public function getDisplayName ($plural=true) {
return Yii::t('calendar', 'Calendar');
} | Class | 2 |
public function __construct($message, $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
} | Base | 1 |
public function deleteUser(){
$login_user = $this->checkLogin();
$this->checkAdmin();
$uid = I("uid/d");
if (D("Item")->where("uid = '$uid' and is_del = 0 ")->find()) {
$this->sendError(10101,"该用户名下还有项目,不允许删除。请先将其项目删除或者重新分配/转让");
return ;
}
$return = D("User")->delete_user($uid);
if (!$return) {
$this->sendError(10101);
}else{
$this->sendResult($return);
}
} | Compound | 4 |
public static function newFromStyle( $style, \DPL\Parameters $parameters ) {
$style = strtolower( $style );
switch ( $style ) {
case 'definition':
$class = 'DefinitionHeading';
break;
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
case 'header':
$class = 'TieredHeading';
break;
case 'ordered':
$class = 'OrderedHeading';
break;
case 'unordered':
$class = 'UnorderedHeading';
break;
default:
return null;
break;
}
$class = '\DPL\Heading\\' . $class;
return new $class( $parameters );
} | Class | 2 |
public static function checkIp6($requestIp, $ip)
{
if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) {
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
}
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ($netmask < 1 || $netmask > 128) {
return false;
}
} else {
$address = $ip;
$netmask = 128;
}
$bytesAddr = unpack('n*', inet_pton($address));
$bytesTest = unpack('n*', inet_pton($requestIp));
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
$left = $netmask - 16 * ($i - 1);
$left = ($left <= 16) ? $left : 16;
$mask = ~(0xffff >> $left) & 0xffff;
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {
return false;
}
}
return true;
} | Base | 1 |
static function isSearchable() { return true; }
| Base | 1 |
public function uniqueName($dir, $name, $suffix = ' copy', $checkNum = true, $start = 1) {
$ext = '';
if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
$ext = '.'.$m[1];
$name = substr($name, 0, strlen($name)-strlen($m[0]));
}
if ($checkNum && preg_match('/('.preg_quote($suffix, '/').')(\d*)$/i', $name, $m)) {
$i = (int)$m[2];
$name = substr($name, 0, strlen($name)-strlen($m[2]));
} else {
$i = $start;
$name .= $suffix;
}
$max = $i+100000;
while ($i <= $max) {
$n = $name.($i > 0 ? $i : '').$ext;
if (!$this->stat($this->joinPathCE($dir, $n))) {
$this->clearcache();
return $n;
}
$i++;
} | Base | 1 |
function addDiscountToCart() {
// global $user, $order;
global $order;
//lookup discount to see if it's real and valid, and not already in our cart
//this will change once we allow more than one coupon code
$discount = new discounts();
$discount = $discount->getCouponByName($this->params['coupon_code']);
if (empty($discount)) {
flash('error', gt("This discount code you entered does not exist."));
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
}
//check to see if it's in our cart already
if ($this->isDiscountInCart($discount->id)) {
flash('error', gt("This discount code is already in your cart."));
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
}
//this should really be reworked, as it shoudn't redirect directly and not return
$validateDiscountMessage = $discount->validateDiscount();
if ($validateDiscountMessage == "") {
//if all good, add to cart, otherwise it will have redirected
$od = new order_discounts();
$od->orders_id = $order->id;
$od->discounts_id = $discount->id;
$od->coupon_code = $discount->coupon_code;
$od->title = $discount->title;
$od->body = $discount->body;
$od->save();
// set this to just the discount applied via this coupon?? if so, when though? $od->discount_total = ??;
flash('message', gt("The discount code has been applied to your cart."));
} else {
flash('error', $validateDiscountMessage);
}
//redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
expHistory::back();
} | Class | 2 |
public static function dropdown($vars){
if(is_array($vars)){
//print_r($vars);
$name = $vars['name'];
$where = "WHERE ";
if(isset($vars['type'])) {
$where .= " `type` = '{$vars['type']}' AND ";
}else{
$where .= " ";
}
$where .= " `status` = '1' ";
$order_by = "ORDER BY ";
if(isset($vars['order_by'])) {
$order_by .= " {$vars['order_by']} ";
}else{
$order_by .= " `name` ";
}
if (isset($vars['sort'])) {
$sort = " {$vars['sort']}";
}else{
$sort = 'ASC';
}
}
$cat = Db::result("SELECT * FROM `posts` {$where} {$order_by} {$sort}");
$num = Db::$num_rows;
$drop = "<select name=\"{$name}\" class=\"form-control\"><option></option>";
if($num > 0){
foreach ($cat as $c) {
# code...
// if($c->parent == ''){
if(isset($vars['selected']) && $c->id == $vars['selected']) $sel = "SELECTED"; else $sel = "";
$drop .= "<option value=\"{$c->id}\" $sel style=\"padding-left: 10px;\">{$c->title}</option>";
// foreach ($cat as $c2) {
// # code...
// if($c2->parent == $c->id){
// if(isset($vars['selected']) && $c2->id == $vars['selected']) $sel = "SELECTED"; else $sel = "";
// $drop .= "<option value=\"{$c2->id}\" $sel style=\"padding-left: 10px;\"> {$c2->name}</option>";
// }
// }
// }
}
}
$drop .= "</select>";
return $drop;
} | Base | 1 |
function mso_current_url($absolute = false, $explode = false, $delete_request = false)
{
$url = getinfo('site_protocol') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if ($delete_request) {
// отделим по «?»
$url = explode('?', $url);
$url = $url[0];
}
if ($absolute) return $url;
$url = str_replace(getinfo('site_url'), '', $url);
$url = trim(str_replace('/', ' ', $url));
$url = str_replace(' ', '/', $url);
$url = urldecode($url);
if ($explode) $url = explode('/', $url);
return $url;
}
| Base | 1 |
function mso_url_get()
{
$CI = &get_instance();
if (isset($_SERVER['REQUEST_URI']) and $_SERVER['REQUEST_URI'] and (strpos($_SERVER['REQUEST_URI'], '?') !== FALSE)) {
$url = getinfo('site_protocol') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url = str_replace($CI->config->config['base_url'], "", $url);
$url = explode('?', $url);
return $url[1];
} else {
return '';
}
}
| 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 |
function showallSubcategories() {
// global $db;
expHistory::set('viewable', $this->params);
// $parent = isset($this->params['cat']) ? $this->params['cat'] : expSession::get('catid');
$catid = expSession::get('catid');
$parent = !empty($catid) ? $catid : (!empty($this->params['cat']) ? $this->params['cat'] : 0);
$category = new storeCategory($parent);
$categories = $category->getEcomSubcategories();
$ancestors = $category->pathToNode();
assign_to_template(array(
'categories' => $categories,
'ancestors' => $ancestors,
'category' => $category
));
} | Class | 2 |
$pfTaskJob->update($input);
$tasks_id = $data['plugin_glpiinventory_tasks_id'];
}
} else {
// case 2: if not exist, create a new task + taskjob
$this->getFromDB($packages_id);
//Add the new task
$input = [
'name' => '[deploy on demand] ' . $this->fields['name'],
'entities_id' => $computer->fields['entities_id'],
'reprepare_if_successful' => 0,
'is_deploy_on_demand' => 1,
'is_active' => 1,
];
$tasks_id = $pfTask->add($input);
//Add a new job for the newly created task
//and enable it
$input = [
'plugin_glpiinventory_tasks_id' => $tasks_id,
'entities_id' => $computer->fields['entities_id'],
'name' => 'deploy',
'method' => 'deployinstall',
'targets' => '[{"PluginGlpiinventoryDeployPackage":"' . $packages_id . '"}]',
'actors' => exportArrayToDB([['Computer' => $computers_id]]),
'enduser' => exportArrayToDB([$users_id => [$computers_id]]),
];
$pfTaskJob->add($input);
}
//Prepare the task (and only this one)
$pfTask->prepareTaskjobs(['deployinstall'], $tasks_id);
} | Base | 1 |
function dashboard_panel_top_pages($params)
{
global $DB;
global $website;
$stats = &$params['statistics'];
$navibars = &$params['navibars'];
/* TOP PAGES */
$sql = '
SELECT i.views as page_views, i.id as id_item, i.category as id_category, p.views as path_views, p.path as path
FROM nv_items i, nv_paths p
WHERE i.website = '.protect($website->id).'
AND i.template > 0
AND i.embedding = 0
AND p.website = '.protect($website->id).'
AND p.type = "item"
AND p.object_id = i.id
UNION ALL
SELECT s.views as page_views, NULL as id_item, s.id as id_category, p.views as path_views, p.path as path
FROM nv_structure s, nv_paths p
WHERE s.website = '.protect($website->id).'
AND p.website = '.protect($website->id).'
AND p.type = "structure"
AND p.object_id = s.id
ORDER BY path_views DESC
LIMIT 10
';
$DB->query($sql, 'array');
$pages = $DB->result();
$pages_html = '';
$url = $website->protocol;
if(!empty($website->subdomain))
$url .= $website->subdomain.'.';
$url .= $website->domain;
$url .= $website->folder;
for($e = 0; $e < 10; $e++)
{
if(!$pages[$e]) break;
$pages_html .= '<div class="navigate-panel-recent-comments-username ui-corner-all items-comment-status-public">'.
'<a href="'.$url.$pages[$e]['path'].'" target="_blank">'.
'<strong>'.$pages[$e]['path_views'].'</strong> <img align="absmiddle" src="img/icons/silk/bullet_star.png" align="absmiddle"> '.$pages[$e]['path'].
'</a>'.
'</div>';
}
$navibars->add_tab_content_panel(
'<img src="img/icons/silk/award_star_gold_3.png" align="absmiddle" /> '.t(296, 'Top pages'),
$pages_html,
'navigate-panel-top-pages',
'100%',
'314px'
);
}
| 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 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 |
elseif ( $columns['TITLE'] )
{
$id_new = DBSeqNextID( 'school_marking_periods_marking_period_id_seq' );
$sql = "INSERT INTO SCHOOL_MARKING_PERIODS ";
$fields = "MARKING_PERIOD_ID,MP,SYEAR,SCHOOL_ID,";
$values = "'" . $id_new . "','" . $_REQUEST['mp_term'] . "','" . UserSyear() . "','" . UserSchool() . "',";
switch ( $_REQUEST['mp_term'] )
{
case 'SEM':
$fields .= "PARENT_ID,";
$values .= "'" . $_REQUEST['year_id'] . "',";
break;
case 'QTR':
$fields .= "PARENT_ID,";
$values .= "'" . $_REQUEST['semester_id'] . "',";
break;
case 'PRO':
$fields .= "PARENT_ID,";
$values .= "'" . $_REQUEST['quarter_id'] . "',";
break;
}
$go = false;
foreach ( (array) $columns as $column => $value )
{
if ( $column === 'START_DATE'
|| $column === 'END_DATE'
|| $column === 'POST_START_DATE'
|| $column === 'POST_END_DATE' )
{
//FJ fix SQL bug START_DATE or END_DATE is null
if ( ! VerifyDate( $value )
&& $value !== ''
|| ( ( $column === 'START_DATE'
|| $column === 'END_DATE' )
&& $value === '' ) )
{
$error[] = _( 'Not all of the dates were entered correctly.' );
break 2;
}
//FJ verify END_DATE > START_DATE
if ( ( $column === 'END_DATE'
&& date_create( $value ) <= date_create( $columns['START_DATE'] ) )
|| ( $column === 'POST_START_DATE'
&& $columns['POST_END_DATE'] !== ''
&& date_create( $value ) > date_create( $columns['POST_END_DATE'] ) ) )
{
$error[] = _( 'Start date must be anterior to end date.' );
break 2;
}
}
if ( ! empty( $value )
|| $value === '0' )
{
$fields .= $column . ',';
$values .= "'" . $value . "',";
$go = true;
}
}
$sql .= '(' . mb_substr( $fields, 0, -1 ) . ') values(' . mb_substr( $values, 0, -1 ) . ')';
} | Base | 1 |
public function __construct()
{
# code...
self::$smtphost = Options::v('smtphost');
self::$smtpuser = Options::v('smtpuser');
self::$smtppass = Options::v('smtppass');
self::$smtpport = Options::v('smtpport');
self::$siteemail = Options::v('siteemail');
self::$sitename = Options::v('sitename');
}
| Base | 1 |
$count += $db->dropTable($basename);
}
flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');
expHistory::back();
} | Class | 2 |
public function getPath()
{
return $this->path == null ? '' : $this->path;
} | Base | 1 |
public function execute(&$params){
$options = &$this->config['options'];
$notif = new Notification;
$notif->user = $this->parseOption('user', $params);
$notif->createdBy = 'API';
$notif->createDate = time();
// file_put_contents('triggerLog.txt',"\n".$notif->user,FILE_APPEND);
// if($this->parseOption('type',$params) == 'auto') {
// if(!isset($params['model']))
// return false;
// $notif->modelType = get_class($params['model']);
// $notif->modelId = $params['model']->id;
// $notif->type = $this->getNotifType();
// } else {
$notif->type = 'custom';
$notif->text = $this->parseOption('text', $params);
// }
if ($notif->save()) {
return array (true, "");
} else {
return array(false, array_shift($notif->getErrors()));
}
} | Base | 1 |
foreach ($aco_value_array as $aco_value) {
$this->debug_text("shift_acl(): ACO Section Value: $aco_section_value ACO VALUE: $aco_value");
$aco_key = array_search($aco_value, $acl_array['aco'][$aco_section_value]);
if ($aco_key !== FALSE) {
$this->debug_text("shift_acl(): Removing ACO. ($aco_key)");
unset($acl_array['aco'][$aco_section_value][$aco_key]);
$update = 1;
} else {
$this->debug_text("shift_acl(): ACO doesn't exist, can't remove it.");
}
} | Class | 2 |
public function edit()
{
if((isset($this->params['id']))) $record = new address(intval($this->params['id']));
else $record = null;
$config = ecomconfig::getConfig('address_allow_admins_all');
assign_to_template(array(
'record'=>$record,
'admin_config'=>$config
));
if (expSession::get('customer-signup')) {
assign_to_template(array(
'checkout'=>true
));
}
} | Class | 2 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.