code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
function dump() {
if (!$this->output)
$this->output = fopen('php://output', 'w');
// Detect delimeter from the current locale settings. For locales
// which use comma (,) as the decimal separator, the semicolon (;)
// should be used as the field separator
$delimiter = ',';
if (class_exists('NumberFormatter')) {
$nf = NumberFormatter::create(Internationalization::getCurrentLocale(),
NumberFormatter::DECIMAL);
$s = $nf->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
if ($s == ',')
$delimiter = ';';
}
// Output a UTF-8 BOM (byte order mark)
fputs($this->output, chr(0xEF) . chr(0xBB) . chr(0xBF));
fputcsv($this->output, $this->getHeaders(), $delimiter);
while ($row=$this->next())
fputcsv($this->output, $row, $delimiter);
fclose($this->output);
} | Base | 1 |
form_selectable_cell(filter_value($vdef['name'], get_request_var('filter'), 'vdef.php?action=edit&id=' . $vdef['id']), $vdef['id']);
form_selectable_cell($disabled ? __('No'):__('Yes'), $vdef['id'], '', 'text-align:right');
form_selectable_cell(number_format_i18n($vdef['graphs'], '-1'), $vdef['id'], '', 'text-align:right');
form_selectable_cell(number_format_i18n($vdef['templates'], '-1'), $vdef['id'], '', 'text-align:right');
form_checkbox_cell($vdef['name'], $vdef['id'], $disabled);
form_end_row();
} | Base | 1 |
public static function evaluate_search_tree($tree, $join = 'AND', $callback)
{
$matches = false;
foreach($tree as $i => $el)
{
$b = false;
if($i === 'AND' || $i === 'OR')
{
$b = self::evaluate_search_tree($el, $i, $callback);
}
else if(isset($el['query']))
{
$b = call_user_func($callback, $el['query']);
if($el['not'])
{
$b = !$b;
}
}
else if(is_array($el))
{
$b = self::evaluate_search_tree($el, $join, $callback);
}
if($join == 'AND')
{
if(!$b)
{
return false;
}
$matches = true;
}
else if($join == 'OR')
{
if($b)
{
return true;
}
$matches = $matches || $b;
}
}
return $matches;
} | Base | 1 |
public function approve_submit() {
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for comment to approve'));
expHistory::back();
}
/* 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'];
$comment = new expComment($this->params['id']);
$comment->body = $this->params['body'];
$comment->approved = $this->params['approved'];
$comment->save();
expHistory::back();
} | 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 |
}elseif($k2 == ''){
$va = ['default'];
}else{
| Base | 1 |
public static function canImportData() {
return true;
}
| Class | 2 |
public function __construct() {
}
| Base | 1 |
foreach ($days as $value) {
$regitem[] = $value;
}
| Base | 1 |
protected function _joinPath($dir, $name)
{
return rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name;
} | Base | 1 |
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();
} | Base | 1 |
public function confirm()
{
$task = $this->getTask();
$comment = $this->getComment();
$this->response->html($this->template->render('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')
)));
} | Base | 1 |
public static function initializeNavigation() {
$sections = section::levelTemplate(0, 0);
return $sections;
}
| Base | 1 |
public function admin_log($mode = '')
{
$errorLogPath = TMP . 'logs' . DS . 'error.log';
switch($mode) {
case 'download':
set_time_limit(0);
if ($this->_downloadErrorLog()) {
exit();
}
$this->BcMessage->setInfo('γ¨γ©γΌγγ°γεε¨γγΎγγγ');
$this->redirect(['action' => 'log']);
break;
case 'delete':
$this->_checkSubmitToken();
if (file_exists($errorLogPath)) {
if (unlink($errorLogPath)) {
$messages[] = __d('baser', 'γ¨γ©γΌγγ°γει€γγΎγγγ');
$error = false;
} else {
$messages[] = __d('baser', 'γ¨γ©γΌγγ°γει€γ§γγΎγγγ§γγγ');
$error = true;
}
} else {
$messages[] = __d('baser', 'γ¨γ©γΌγγ°γεε¨γγΎγγγ');
$error = false;
}
if ($messages) {
$this->BcMessage->set(implode("\n", $messages), $error);
}
$this->redirect(['action' => 'log']);
break;
}
$fileSize = 0;
if (file_exists($errorLogPath)) {
$fileSize = filesize($errorLogPath);
}
$this->pageTitle = __d('baser', 'γγΌγΏγ‘γ³γγγ³γΉ');
$this->help = 'tools_log';
$this->set('fileSize', $fileSize);
} | Base | 1 |
public static function checkPermissions($permission,$location) {
global $exponent_permissions_r, $router;
// only applies to the 'manage' method
if (empty($location->src) && empty($location->int) && (!empty($router->params['action']) && $router->params['action'] == 'manage') || strpos($router->current_url, 'action=manage') !== false) {
if (!empty($exponent_permissions_r['navigation'])) foreach ($exponent_permissions_r['navigation'] as $page) {
foreach ($page as $pageperm) {
if (!empty($pageperm['manage'])) return true;
}
}
}
return false;
}
| Base | 1 |
public function confirm()
{
$task = $this->getTask();
$comment = $this->getComment();
$this->response->html($this->template->render('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')
)));
} | Class | 2 |
public function showall() {
expHistory::set('viewable', $this->params);
$limit = (isset($this->config['limit']) && $this->config['limit'] != '') ? $this->config['limit'] : 10;
if (!empty($this->params['view']) && ($this->params['view'] == 'showall_accordion' || $this->params['view'] == 'showall_tabbed')) {
$limit = '0';
}
$order = isset($this->config['order']) ? $this->config['order'] : "rank";
$page = new expPaginator(array(
'model'=>'photo',
'where'=>$this->aggregateWhereClause(),
'limit'=>$limit,
'order'=>$order,
'categorize'=>empty($this->config['usecategories']) ? false : $this->config['usecategories'],
'uncat'=>!empty($this->config['uncat']) ? $this->config['uncat'] : gt('Not Categorized'),
'groups'=>!isset($this->params['gallery']) ? array() : array($this->params['gallery']),
'grouplimit'=>!empty($this->params['view']) && $this->params['view'] == 'showall_galleries' ? 1 : null,
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'columns'=>array(
gt('Title')=>'title'
),
));
assign_to_template(array(
'page'=>$page,
'params'=>$this->params,
));
} | Base | 1 |
$result = $search->getSearchResults($item->query, false, true);
if(empty($result) && !in_array($item->query, $badSearchArr)) {
$badSearchArr[] = $item->query;
$badSearch[$ctr2]['query'] = $item->query;
$badSearch[$ctr2]['count'] = $db->countObjects("search_queries", "query='{$item->query}'");
$ctr2++;
}
}
//Check if the user choose from the dropdown
if(!empty($user_default)) {
if($user_default == $anonymous) {
$u_id = 0;
} else {
$u_id = $user_default;
}
$where .= "user_id = {$u_id}";
}
//Get all the search query records
$records = $db->selectObjects('search_queries', $where);
for ($i = 0, $iMax = count($records); $i < $iMax; $i++) {
if(!empty($records[$i]->user_id)) {
$u = user::getUserById($records[$i]->user_id);
$records[$i]->user = $u->firstname . ' ' . $u->lastname;
}
}
$page = new expPaginator(array(
'records' => $records,
'where'=>1,
'model'=>'search_queries',
'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? 10 : $this->config['limit'],
'order'=>empty($this->config['order']) ? 'timestamp' : $this->config['order'],
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'columns'=>array(
'ID'=>'id',
gt('Query')=>'query',
gt('Timestamp')=>'timestamp',
gt('User')=>'user_id',
),
));
$uname['id'] = implode($uname['id'],',');
$uname['name'] = implode($uname['name'],',');
assign_to_template(array(
'page'=>$page,
'users'=>$uname,
'user_default' => $user_default,
'badSearch' => $badSearch
));
} | Class | 2 |
public function getAmount()
{
$amount = $this->getParameter('amount');
if ($amount !== null) {
// Don't allow integers for currencies that support decimals.
// This is for legacy reasons - upgrades from v0.9
if ($this->getCurrencyDecimalPlaces() > 0) {
if (is_int($amount) || (is_string($amount) && false === strpos((string) $amount, '.'))) {
throw new InvalidRequestException(
'Please specify amount as a string or float, '
. 'with decimal places (e.g. \'10.00\' to represent $10.00).'
);
};
}
$amount = $this->toFloat($amount);
// Check for a negative amount.
if (!$this->negativeAmountAllowed && $amount < 0) {
throw new InvalidRequestException('A negative amount is not allowed.');
}
// Check for a zero amount.
if (!$this->zeroAmountAllowed && $amount === 0.0) {
throw new InvalidRequestException('A zero amount is not allowed.');
}
// Check for rounding that may occur if too many significant decimal digits are supplied.
$decimal_count = strlen(substr(strrchr((string)$amount, '.'), 1));
if ($decimal_count > $this->getCurrencyDecimalPlaces()) {
throw new InvalidRequestException('Amount precision is too high for currency.');
}
return $this->formatCurrency($amount);
}
} | Base | 1 |
public function show()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask_restriction/show', array(
'status_list' => array(
SubtaskModel::STATUS_TODO => t('Todo'),
SubtaskModel::STATUS_DONE => t('Done'),
),
'subtask_inprogress' => $this->subtaskStatusModel->getSubtaskInProgress($this->userSession->getId()),
'subtask' => $subtask,
'task' => $task,
)));
} | Base | 1 |
function checkPassword($username, $password)
{
$doUser = OA_Dal::factoryDO('users');
$doUser->username = strtolower($username);
$doUser->password = md5($password);
$doUser->find();
if ($doUser->fetch()) {
return $doUser;
} else {
return false;
}
} | Class | 2 |
function path_f ($path)
{
global $home_dir;
$abs_dir = $home_dir;
switch ($path)
{
case '.':
case '': return realpath($abs_dir);
}
return realpath(realpath($home_dir) . "/$path");
} | 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 static function stripFolder($req_uri) {
$uri = Site::$url;
$folder = self::getFolder();
$uri2 = str_replace($folder, "", $req_uri);
// print_r($uri2);
return $uri2;
}
| Base | 1 |
function shibboleth_login_form() {
$login_url = add_query_arg('action', 'shibboleth');
$login_url = remove_query_arg('reauth', $login_url);
echo '<p id="shibboleth_login"><a href="' . $login_url . '">' . __('Login with Shibboleth', 'shibboleth') . '</a></p>';
} | Base | 1 |
public function popupnewsitem($id)
{
$query = 'SELECT *
FROM ' . TABLE_PREFIX .'news
WHERE id=' . $id . ' ';
return DB::get_row($query);
} | Base | 1 |
public function addSelect( $fields ) {
if ( !is_array( $fields ) ) {
throw new \MWException( __METHOD__ . ': A non-array was passed.' );
}
foreach ( $fields as $alias => $field ) {
if ( !is_numeric( $alias ) && array_key_exists( $alias, $this->select ) && $this->select[$alias] != $field ) {
//In case of a code bug that is overwriting an existing field alias throw an exception.
throw new \MWException( __METHOD__ . ": Attempted to overwrite existing field alias `{$this->select[$alias]}` AS `{$alias}` with `{$field}` AS `{$alias}`." );
}
//String alias and does not exist already.
if ( !is_numeric( $alias ) && !array_key_exists( $alias, $this->select ) ) {
$this->select[$alias] = $field;
}
//Speed up by not using in_array() or array_key_exists(). Toss the field names into their own array as keys => true to exploit a speedy look up with isset().
if ( is_numeric( $alias ) && !isset( $this->selectedFields[$field] ) ) {
$this->select[] = $field;
$this->selectedFields[$field] = true;
}
}
return true;
} | Class | 2 |
return $fa->nameGlyph($icons, 'icon-');
}
} else {
return array();
}
}
| Base | 1 |
$ok = $DB->execute('
INSERT INTO nv_paths
(id, website, type, object_id, lang, path, cache_file, cache_expires, views)
VALUES
( 0, :website, :type, :object_id, :lang, :path, "", 0, :views )
',
array(
':website' => $website_id,
':type' => $type,
':object_id' => $object_id,
':lang' => $lang,
':path' => $path,
':views' => 0,
)
);
if(!$ok) throw new Exception($DB->get_last_error());
}
| Base | 1 |
public function getItemLink(&$icmsObj, $onlyUrl=false) {
/**
* @todo URL Rewrite feature is not finished yet...
*/
//$seoMode = smart_getModuleModeSEO($this->handler->_moduleName);
//$seoModuleName = smart_getModuleNameForSEO($this->handler->_moduleName);
$seoMode = false;
$seoModuleName = $this->handler->_moduleName;
/**
* $seoIncludeId feature is not finished yet, so let's put it always to true
*/
//$seoIncludeId = smart_getModuleIncludeIdSEO($this->handler->_moduleName);
$seoIncludeId = true;
/*if ($seoMode == 'rewrite') {
$ret = ICMS_URL . '/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $icmsObj->getVar($this->handler->keyName) : ''). '/' . $icmsObj->getVar('short_url') . '.html';
} else if ($seoMode == 'pathinfo') {
$ret = SMARTOBJECT_URL . 'seo.php/' . $seoModuleName . '.' . $this->handler->_itemname . ($seoIncludeId ? '.' . $icmsObj->getVar($this->handler->keyName) : ''). '/' . $icmsObj->getVar('short_url') . '.html';
} else {
*/ $ret = $this->handler->_moduleUrl . $this->handler->_page . "?" . $this->handler->keyName . "=" . $icmsObj->getVar($this->handler->keyName);
//}
if (!$onlyUrl) {
$ret = "<a href='" . $ret . "'>" . $icmsObj->getVar($this->handler->identifierName) . "</a>";
}
return $ret;
}
| Base | 1 |
static function displayname() {
return gt("e-Commerce Category Manager");
} | Base | 1 |
protected function getFile()
{
$task_id = $this->request->getIntegerParam('task_id');
$file_id = $this->request->getIntegerParam('file_id');
$model = 'projectFileModel';
if ($task_id > 0) {
$model = 'taskFileModel';
$project_id = $this->taskFinderModel->getProjectId($task_id);
if ($project_id !== $this->request->getIntegerParam('project_id')) {
throw new AccessForbiddenException();
}
}
$file = $this->$model->getById($file_id);
if (empty($file)) {
throw new PageNotFoundException();
}
$file['model'] = $model;
return $file;
} | Class | 2 |
public function breadcrumb() {
global $sectionObj;
expHistory::set('viewable', $this->params);
$id = $sectionObj->id;
$current = null;
// Show not only the location of a page in the hierarchy but also the location of a standalone page
$current = new section($id);
if ($current->parent == -1) { // standalone page
$navsections = section::levelTemplate(-1, 0);
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
} else {
$navsections = section::levelTemplate(0, 0);
foreach ($navsections as $section) {
if ($section->id == $id) {
$current = $section;
break;
}
}
}
assign_to_template(array(
'sections' => $navsections,
'current' => $current,
));
}
| Base | 1 |
function unlockTables() {
$sql = "UNLOCK TABLES";
$res = mysqli_query($this->connection, $sql);
return $res;
} | Base | 1 |
protected function removeNetVolume($key) {
$netVolumes = $this->getNetVolumes();
if (is_string($key) && isset($netVolumes[$key])) {
unset($netVolumes[$key]);
$this->saveNetVolumes($netVolumes);
}
} | Base | 1 |
protected function __construct() {
parent::__construct();
self::$locale = fusion_get_locale('', LOCALE.LOCALESET.'search.php');
} | Base | 1 |
static function convertUTF($string) {
return $string = str_replace('?', '', htmlspecialchars($string, ENT_IGNORE, 'UTF-8'));
} | Class | 2 |
public function getXForwardedForData()
{
return array(
array(false, '10.0.0.1'),
array('10.0.0.2', '10.0.0.2, 10.0.0.1'),
array('10.0.0.2, 10.0.0.3', '10.0.0.2, 10.0.0.3, 10.0.0.1'),
);
} | Class | 2 |
$files[$key]->save();
}
// eDebug($files,true);
} | Class | 2 |
public function search_external() {
// global $db, $user;
global $db;
$sql = "select DISTINCT(a.id) as id, a.source as source, a.firstname as firstname, a.middlename as middlename, a.lastname as lastname, a.organization as organization, a.email as email ";
$sql .= "from " . $db->prefix . "external_addresses as a "; //R JOIN " .
//$db->prefix . "billingmethods as bm ON bm.addresses_id=a.id ";
$sql .= " WHERE match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] .
"*' IN BOOLEAN MODE) ";
$sql .= "order by match (a.firstname,a.lastname,a.email,a.organization) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) ASC LIMIT 12";
$res = $db->selectObjectsBySql($sql);
foreach ($res as $key=>$record) {
$res[$key]->title = $record->firstname . ' ' . $record->lastname;
}
//eDebug($sql);
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Class | 2 |
public static function isHadSub($parent, $menuid =''){
$sql = sprintf("SELECT * FROM `menus` WHERE `parent` = '%s' %s", $parent, $where);
} | Base | 1 |
function html_escape_request_var($string) {
return htmlspecialchars(get_request_var($string), ENT_QUOTES, 'UTF-8');
} | Base | 1 |
public function update_version() {
// get the current version
$hv = new help_version();
$current_version = $hv->find('first', 'is_current=1');
// check to see if the we have a new current version and unset the old current version.
if (!empty($this->params['is_current'])) {
// $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0');
help_version::clearHelpVersion();
}
expSession::un_set('help-version');
// save the version
$id = empty($this->params['id']) ? null : $this->params['id'];
$version = new help_version();
// if we don't have a current version yet so we will force this one to be it
if (empty($current_version->id)) $this->params['is_current'] = 1;
$version->update($this->params);
// if this is a new version we need to copy over docs
if (empty($id)) {
self::copydocs($current_version->id, $version->id);
}
// let's update the search index to reflect the current help version
searchController::spider();
flash('message', gt('Saved help version').' '.$version->version);
expHistory::back();
} | Base | 1 |
public function getChart($renderer, $id, $store_in_session = true)
{
$c = null;
$chart_data = null;
if ($renderer != null && $store_in_session) {
$session = new Tracker_Report_Session($renderer->report->id);
$session->changeSessionNamespace("renderers.{$renderer->id}");
// look for the chart in the session
$chart_data = $session->get("charts.$id");
}
if (! $chart_data) {
// not found. look in the db
$dao = new GraphOnTrackersV5_ChartDao(CodendiDataAccess::instance());
$chart_data = $dao->searchById($id)->getRow();
}
if ($chart_data) {
if (! $renderer) {
$report = null; //We don't know the report
$renderer = Tracker_Report_RendererFactory::instance()->getReportRendererById($chart_data['report_graphic_id'], $report, $store_in_session);
}
if ($renderer) {
$c = $this->instanciateChart($chart_data, $renderer, $store_in_session);
}
}
return $c;
} | Class | 2 |
public static function isPublic($s) {
if ($s == null) {
return false;
}
while ($s->public && $s->parent > 0) {
$s = new section($s->parent);
}
$lineage = (($s->public) ? 1 : 0);
return $lineage;
}
| Class | 2 |
public function __construct($page, $file = null) {
$this->page = $page;
$this->file = $file;
$this->blueprint = $page->blueprint();
$this->filename = $this->blueprint->files()->sanitize() ? '{safeFilename}' : '{filename}';
if($this->file) {
$this->replace();
} else {
$this->upload();
}
} | Base | 1 |
$this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);
} | Class | 2 |
$expanded = implode($joiner, $kvp);
if ($isAssoc) {
// Don't prepend the value name when using the explode
// modifier with an associative array.
$actuallyUseQuery = false;
}
} else {
if ($isAssoc) {
// When an associative array is encountered and the
// explode modifier is not set, then the result must be
// a comma separated list of keys followed by their
// respective values.
foreach ($kvp as $k => &$v) {
$v = $k . ',' . $v;
}
}
$expanded = implode(',', $kvp);
}
} else {
if ($value['modifier'] == ':') {
$variable = substr($variable, 0, $value['position']);
}
$expanded = rawurlencode($variable);
if ($parsed['operator'] == '+' || $parsed['operator'] == '#') {
$expanded = $this->decodeReserved($expanded);
}
}
if ($actuallyUseQuery) {
if (!$expanded && $joiner != '&') {
$expanded = $value['value'];
} else {
$expanded = $value['value'] . '=' . $expanded;
}
}
$replacements[] = $expanded;
}
$ret = implode($joiner, $replacements);
if ($ret && $prefix) {
return $prefix . $ret;
}
return $ret;
} | Base | 1 |
public function testCanTransformAndRetrievePartsIndividually()
{
$uri = (new Uri(''))
->withFragment('#test')
->withHost('example.com')
->withPath('path/123')
->withPort(8080)
->withQuery('?q=abc')
->withScheme('http')
->withUserInfo('user', 'pass');
// Test getters.
$this->assertEquals('user:[email protected]:8080', $uri->getAuthority());
$this->assertEquals('test', $uri->getFragment());
$this->assertEquals('example.com', $uri->getHost());
$this->assertEquals('path/123', $uri->getPath());
$this->assertEquals(8080, $uri->getPort());
$this->assertEquals('q=abc', $uri->getQuery());
$this->assertEquals('http', $uri->getScheme());
$this->assertEquals('user:pass', $uri->getUserInfo());
} | Base | 1 |
public function rules()
{
$rules = [];
$inputs = $this->all();
$validateEmail = false;
$validateUsername = false;
if (!isset($inputs['username']) || !isset($inputs['email'])) {
$validateUsername = true;
}
if (isset($inputs['email']) && !isset($inputs['username'])) {
$validateUsername = false;
$validateEmail = true;
}
if (isset($inputs['email']) && isset($inputs['username'])) {
$validateUsername = true;
$validateEmail = true;
}
if ($validateEmail) {
$rules['email'] = 'email|string|min:3|required|string|max:255|unique:users';
}
if ($validateUsername) {
$rules['username'] = 'alpha_dash|string|min:1|required|string|max:255|unique:users';
}
if (isset($inputs['confirm_password'])) {
$rules['confirm_password'] = 'required|min:1|same:password';
}
if (get_option('captcha_disabled', 'users') !== 'y') {
$rules['captcha'] = 'captcha';
}
if (isset($inputs['email']) && $inputs['email'] != false && ((get_option('disable_registration_with_temporary_email', 'users') == 'y'))) {
$rules['email'] = $rules['email'] . '|temporary_email_check';
}
if (get_option('require_terms', 'users') == 'y') {
$rules['terms'] = 'terms:terms_user';
if (isset($inputs['newsletter_subscribe']) and $inputs['newsletter_subscribe']) {
$rules['terms'] = $rules['terms'] . ', terms_newsletter';
}
}
$rules['password'] = 'required|min:1';
return $rules;
} | Base | 1 |
function edit_optiongroup_master() {
expHistory::set('editable', $this->params);
$id = isset($this->params['id']) ? $this->params['id'] : null;
$record = new optiongroup_master($id);
assign_to_template(array(
'record'=>$record
));
} | Base | 1 |
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMainRequest()) {
return;
}
$request = $event->getRequest();
if (!$request->hasSession() || !$request->attributes->get('_security_firewall_run', false)) {
return;
}
if ($this->dispatcher) {
$this->dispatcher->removeListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
}
$this->registered = false;
$session = $request->getSession();
$sessionId = $session->getId();
$usageIndexValue = $session instanceof Session ? $usageIndexReference = &$session->getUsageIndex() : null;
$token = $this->tokenStorage->getToken();
if (null === $token || $this->trustResolver->isAnonymous($token)) {
if ($request->hasPreviousSession()) {
$session->remove($this->sessionKey);
}
} else {
$session->set($this->sessionKey, serialize($token));
if (null !== $this->logger) {
$this->logger->debug('Stored the security token in the session.', ['key' => $this->sessionKey]);
}
}
if ($this->sessionTrackerEnabler && $session->getId() === $sessionId) {
$usageIndexReference = $usageIndexValue;
}
} | Class | 2 |
public static function simple($input)
{
return empty($str) ? '' : pts_strings::keep_in_string($input, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COMMA | pts_strings::CHAR_AT | pts_strings::CHAR_COLON);
} | Compound | 4 |
public function toolbar() {
// global $user;
$menu = array();
$dirs = array(
BASE.'framework/modules/administration/menus',
BASE.'themes/'.DISPLAY_THEME.'/modules/administration/menus'
);
foreach ($dirs as $dir) {
if (is_readable($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if (substr($file,-4,4) == '.php' && is_readable($dir.'/'.$file) && is_file($dir.'/'.$file)) {
$menu[substr($file,0,-4)] = include($dir.'/'.$file);
if (empty($menu[substr($file,0,-4)])) unset($menu[substr($file,0,-4)]);
}
}
}
}
// sort the top level menus alphabetically by filename
ksort($menu);
$sorted = array();
foreach($menu as $m) $sorted[] = $m;
// slingbar position
if (isset($_COOKIE['slingbar-top'])){
$top = $_COOKIE['slingbar-top'];
} else {
$top = SLINGBAR_TOP;
}
assign_to_template(array(
'menu'=>(bs3()) ? $sorted : json_encode($sorted),
"top"=>$top
));
} | Class | 2 |
foreach($course_RET as $period_day)
{
$period_days_append_sql .="(sp.start_time<='$period_day[END_TIME]' AND '$period_day[START_TIME]'<=sp.end_time AND DAYS LIKE '%$period_day[DAYS]%') OR ";
} | Base | 1 |
public function enable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function isAllowedFilename($filename){
$allow_array = array(
'.jpg','.jpeg','.png','.bmp','.gif','.ico','.webp',
'.mp3','.wav','.mp4',
'.mov','.webmv','.flac','.mkv',
'.zip','.tar','.gz','.tgz','.ipa','.apk','.rar','.iso',
'.pdf','.ofd','.swf','.epub','.xps',
'.doc','.docx','.wps',
'.ppt','.pptx','.xls','.xlsx','.txt','.psd','.csv',
'.cer','.ppt','.pub','.json','.css',
) ;
$ext = strtolower(substr($filename,strripos($filename,'.')) ); //θ·εζδ»Άζ©ε±εοΌθ½¬δΈΊε°εεοΌ
if(in_array( $ext , $allow_array ) ){
return true ;
}
return false;
} | Base | 1 |
function singleQuoteReplace($param1 = false, $param2 = false, $param3)
{
return str_replace("'", "''", str_replace("\'", "'", $param3));
} | Base | 1 |
public function testPopBeforeSmtpBad()
{
//Start a fake POP server on a different port
//so we don't inadvertently connect to the previous instance
$pid = shell_exec('nohup ./runfakepopserver.sh 1101 >/dev/null 2>/dev/null & printf "%u" $!');
$this->pids[] = $pid;
sleep(2);
//Test a known-bad login
$this->assertFalse(
POP3::popBeforeSmtp('localhost', 1101, 10, 'user', 'xxx', $this->Mail->SMTPDebug),
'POP before SMTP should have failed'
);
shell_exec('kill -TERM '.escapeshellarg($pid));
sleep(2);
} | Class | 2 |
return "__NOTOC____NOEDITSECTION__" . \CategoryViewer::shortList( $articleLinks, $articleStartChars );
}
return '';
} | Class | 2 |
public function testResolvesUris($base, $rel, $expected)
{
$uri = new Uri($base);
$actual = Uri::resolve($uri, $rel);
$this->assertEquals($expected, (string) $actual);
} | Base | 1 |
function edit_externalalias() {
$section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params);
if ($section->parent == -1) {
notfoundController::handle_not_found();
exit;
} // doesn't work for standalone pages
if (empty($section->id)) {
$section->public = 1;
if (!isset($section->parent)) {
// This is another precaution. The parent attribute
// should ALWAYS be set by the caller.
//FJD - if that's the case, then we should die.
notfoundController::handle_not_authorized();
exit;
//$section->parent = 0;
}
}
assign_to_template(array(
'section' => $section,
'glyphs' => self::get_glyphs(),
));
}
| Class | 2 |
public function AddReplyTo($address, $name = '') {
return $this->AddAnAddress('Reply-To', $address, $name);
} | Base | 1 |
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(),
));
}
| Base | 1 |
$return[$index] = strip_tags($value);
if($return[$index] == 'zero')
$return[$index] = '0';
}
}
elseif($type == ARG_MULTISTRING) {
foreach($return as $index => $value) {
$return[$index] = strip_tags($value);
}
}
else
$return = strip_tags($return);
if(! empty($return) && $type == ARG_NUMERIC) {
if(! is_numeric($return)) {
return preg_replace('([^\d])', '', $return);
}
}
elseif(! empty($return) && $type == ARG_STRING) {
if(! is_string($return))
$return = $defaultvalue;
}
elseif(! empty($return) && $type == ARG_MULTINUMERIC) {
foreach($return as $index => $value) {
if(! is_numeric($value)) {
$return[$index] = preg_replace('([^\d])', '', $value);
}
}
return $return;
}
elseif(! empty($return) && $type == ARG_MULTISTRING) {
foreach($return as $index => $value) {
if(! is_string($value))
$return[$index] = $defaultvalue;
elseif($addslashes)
$return[$index] = addslashes($value);
}
return $return;
}
if(is_string($return)) {
if(strlen($return) == 0)
$return = $defaultvalue;
elseif($addslashes)
$return = addslashes($return);
}
return $return;
} | Class | 2 |
public function StartTLS() {
$this->error = null; # to avoid confusion
if(!$this->connected()) {
$this->error = array("error" => "Called StartTLS() without being connected");
return false;
}
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
$rply = $this->get_lines();
$code = substr($rply,0,3);
if($this->do_debug >= 2) {
$this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
}
if($code != 220) {
$this->error =
array("error" => "STARTTLS not accepted from server",
"smtp_code" => $code,
"smtp_msg" => substr($rply,4));
if($this->do_debug >= 1) {
$this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
}
return false;
}
// Begin encrypted connection
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
return false;
}
return true;
} | 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');
}
| Class | 2 |
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 |
private function decryptContentEncryptionKey($private_key_or_secret) {
switch ($this->header['alg']) {
case 'RSA1_5':
$rsa = $this->rsa($private_key_or_secret, RSA::ENCRYPTION_PKCS1);
$this->content_encryption_key = $rsa->decrypt($this->jwe_encrypted_key);
break;
case 'RSA-OAEP':
$rsa = $this->rsa($private_key_or_secret, RSA::ENCRYPTION_OAEP);
$this->content_encryption_key = $rsa->decrypt($this->jwe_encrypted_key);
break;
case 'dir':
$this->content_encryption_key = $private_key_or_secret;
break;
case 'A128KW':
case 'A256KW':
case 'ECDH-ES':
case 'ECDH-ES+A128KW':
case 'ECDH-ES+A256KW':
throw new JOSE_Exception_UnexpectedAlgorithm('Algorithm not supported');
default:
throw new JOSE_Exception_UnexpectedAlgorithm('Unknown algorithm');
}
if (!$this->content_encryption_key) {
# NOTE:
# Not to disclose timing difference between CEK decryption error and others.
# Mitigating Bleichenbacher Attack on PKCS#1 v1.5
# ref.) http://inaz2.hatenablog.com/entry/2016/01/26/222303
$this->generateContentEncryptionKey(null);
}
} | Class | 2 |
public function actionGetItems(){
$sql = 'SELECT id, name as value FROM x2_x2leads WHERE name LIKE :qterm ORDER BY name ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = $_GET['term'].'%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result);
Yii::app()->end();
} | Class | 2 |
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'])));
} | Class | 2 |
function _makeExtra($value, $title = '') {
global $THIS_RET;
if ($THIS_RET['WITH_TEACHER_ID'])
$return .= ''._with.': ' . GetTeacher($THIS_RET['WITH_TEACHER_ID']) . '<BR>';
if ($THIS_RET['NOT_TEACHER_ID'])
$return .= ''._notWith.': ' . GetTeacher($THIS_RET['NOT_TEACHER_ID']) . '<BR>';
if ($THIS_RET['WITH_PERIOD_ID'])
$return .= ''._on.': ' . GetPeriod($THIS_RET['WITH_PERIOD_ID']) . '<BR>';
if ($THIS_RET['NOT_PERIOD_ID'])
$return .= ''._notOn.': ' . GetPeriod($THIS_RET['NOT_PERIOD_ID']) . '<BR>';
if ($THIS_RET['PRIORITY'])
$return .= ''._priority.': ' . $THIS_RET['PRIORITY'] . '<BR>';
if ($THIS_RET['MARKING_PERIOD_ID'])
$return .= ''._markingPeriod.': ' . GetMP($THIS_RET['MARKING_PERIOD_ID']) . '<BR>';
return $return;
} | Base | 1 |
function PMA_linkURL($url)
{
if (!preg_match('#^https?://#', $url) || defined('PMA_SETUP')) {
return $url;
}
if (!function_exists('PMA_URL_getCommon')) {
include_once './libraries/url_generating.lib.php';
}
$params = array();
$params['url'] = $url;
$url = PMA_URL_getCommon($params);
//strip off token and such sensitive information. Just keep url.
$arr = parse_url($url);
parse_str($arr["query"], $vars);
$query = http_build_query(array("url" => $vars["url"]));
$url = './url.php?' . $query;
return $url;
} | Class | 2 |
static function displayname() { return gt("Navigation"); }
| Base | 1 |
public function countFilesInFolder(Folder $folder, $useFilters = true, $recursive = false)
{
$this->assureFolderReadPermission($folder);
$filters = $useFilters ? $this->fileAndFolderNameFilters : [];
return $this->driver->countFilesInFolder($folder->getIdentifier(), $recursive, $filters);
} | Base | 1 |
private function isWindows()
{
return DIRECTORY_SEPARATOR !== '/';
} | Class | 2 |
private function setFooter( $footer ) {
if ( \DynamicPageListHooks::getDebugLevel() == 5 ) {
$footer .= '</nowiki></pre>';
}
$this->footer = $this->replaceVariables( $footer );
} | Class | 2 |
public static function exist($cat)
{
$cat = Typo::int($cat);
$sql = "SELECT `id` FROM `cat` WHERE `id` = '{$cat}' AND `type` = 'post'";
$q = Db::result($sql);
// echo Db::$num_rows;
if (Db::$num_rows > 0) {
return true;
} else {
return false;
}
} | Base | 1 |
foreach ($grpusers as $u) {
$emails[$u->email] = trim(user::getUserAttribution($u->id));
}
| Base | 1 |
} elseif ( $sSecLabel[0] == '{' ) {
// Uses LST::includeTemplate() from LabeledSectionTransclusion extension to include templates from the page
// primary syntax {template}suffix
$template1 = trim( substr( $sSecLabel, 1, strpos( $sSecLabel, '}' ) - 1 ) );
$template2 = trim( str_replace( '}', '', substr( $sSecLabel, 1 ) ) );
// alternate syntax: {template|surrogate}
if ( $template2 == $template1 && strpos( $template1, '|' ) > 0 ) {
$template1 = preg_replace( '/\|.*/', '', $template1 );
$template2 = preg_replace( '/^.+\|/', '', $template2 );
}
//Why the hell was defaultTemplateSuffix be passed all over the place for just fucking here? --Alexia
$secPieces = LST::includeTemplate( $this->parser, $this, $s, $article, $template1, $template2, $template2 . $this->getTemplateSuffix(), $mustMatch, $mustNotMatch, $this->includePageParsed, implode( ', ', $article->mCategoryLinks ) );
$secPiece[$s] = implode( isset( $this->multiSectionSeparators[$s] ) ? $this->replaceTagCount( $this->multiSectionSeparators[$s], $filteredCount ) : '', $secPieces );
if ( $this->getDominantSectionCount() >= 0 && $s == $this->getDominantSectionCount() && count( $secPieces ) > 1 ) {
$dominantPieces = $secPieces;
}
if ( ( $mustMatch != '' || $mustNotMatch != '' ) && count( $secPieces ) <= 1 && $secPieces[0] == '' ) {
$matchFailed = true; // NOTHING MATCHED
break;
}
} else { | Class | 2 |
echo '<LANGUAGE>' . htmlentities($value_arr['LANGUAGE']) . '</LANGUAGE>';
foreach ($value_arr['ENROLLMENT_INFO'] as $eid => $ed) {
echo '<ENROLLMENT_INFO_' . htmlentities($eid) . '>';
echo '<SCHOOL_ID>' . htmlentities($ed['SCHOOL_ID']) . '</SCHOOL_ID>';
echo '<CALENDAR>' . htmlentities($ed['CALENDAR']) . '</CALENDAR>';
echo '<GRADE>' . htmlentities($ed['GRADE']) . '</GRADE>';
echo '<SECTION>' . htmlentities($ed['SECTION']) . '</SECTION>';
echo '<START_DATE>' . htmlentities($ed['START_DATE']) . '</START_DATE>';
echo '<DROP_DATE>' . htmlentities($ed['DROP_DATE']) . '</DROP_DATE>';
echo '<ENROLLMENT_CODE>' . htmlentities($ed['ENROLLMENT_CODE']) . '</ENROLLMENT_CODE>';
echo '<DROP_CODE>' . htmlentities($ed['DROP_CODE']) . '</DROP_CODE>';
echo '</ENROLLMENT_INFO_' . htmlentities($eid) . '>';
}
echo '</STUDENT>';
}
echo '</SCHOOL>';
} | Base | 1 |
function editEvent($selected_events, $queue, $comments)
{
global $database_ged;
// get all needed infos into variables
$value_parts = explode(":", $selected_events);
$id = $value_parts[0];
$ged_type = $value_parts[1];
// format comment string to avoid errors
$comments = str_replace("'", "\'", $comments);
$comments = str_replace("#", "\#", $comments);
$sql = "UPDATE ".$ged_type."_queue_".$queue." SET comments='$comments' WHERE id = $id";
$result = sqlrequest($database_ged, $sql);
if($result){
message(11, " : ".getLabel("message.event_edited"), "ok");
} else {
message(11, " : ".getLabel("message.event_edited_error"), "danger");
}
} | Base | 1 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Base | 1 |
$contents = ['form' => tep_draw_form('countries', 'countries.php', 'page=' . $_GET['page'] . '&action=insert')]; | Base | 1 |
public function getMailingVoucher($id)
{
trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be private with 5.8.', __CLASS__, __METHOD__), E_USER_DEPRECATED);
$sql = 'SELECT value FROM s_campaigns_containers WHERE type=? AND promotionID=?';
$voucherID = Shopware()->Db()->fetchOne($sql, ['ctVoucher', $id]);
if (empty($voucherID)) {
return false;
}
$sql = "
SELECT ev.*, 'VOUCHER123' as code
FROM s_emarketing_vouchers ev
WHERE ev.modus = 1 AND (ev.valid_to >= CURDATE() OR ev.valid_to IS NULL)
AND (ev.valid_from <= CURDATE() OR ev.valid_from IS NULL)
AND ev.id=?
";
return Shopware()->Db()->fetchRow($sql, [$voucherID]);
} | Base | 1 |
public function editspeed() {
global $db;
if (empty($this->params['id'])) return false;
$calcname = $db->selectValue('shippingcalculator', 'calculator_name', 'id='.$this->params['id']);
$calc = new $calcname($this->params['id']);
assign_to_template(array(
'calculator'=>$calc
));
} | Base | 1 |
public function testResource()
{
$stream = Psr7\stream_for('foo');
$handle = StreamWrapper::getResource($stream);
$this->assertSame('foo', fread($handle, 3));
$this->assertSame(3, ftell($handle));
$this->assertSame(3, fwrite($handle, 'bar'));
$this->assertSame(0, fseek($handle, 0));
$this->assertSame('foobar', fread($handle, 6));
$this->assertSame('', fread($handle, 1));
$this->assertTrue(feof($handle));
// This fails on HHVM for some reason
if (!defined('HHVM_VERSION')) {
$this->assertEquals([
'dev' => 0,
'ino' => 0,
'mode' => 33206,
'nlink' => 0,
'uid' => 0,
'gid' => 0,
'rdev' => 0,
'size' => 6,
'atime' => 0,
'mtime' => 0,
'ctime' => 0,
'blksize' => 0,
'blocks' => 0,
0 => 0,
1 => 0,
2 => 33206,
3 => 0,
4 => 0,
5 => 0,
6 => 0,
7 => 6,
8 => 0,
9 => 0,
10 => 0,
11 => 0,
12 => 0,
], fstat($handle));
}
$this->assertTrue(fclose($handle));
$this->assertSame('foobar', (string) $stream);
} | Base | 1 |
public function pending() {
// global $db;
// make sure we have what we need.
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('Your subscriber ID was not supplied.'));
// find the subscriber and their pending subscriptions
$ealerts = expeAlerts::getPendingBySubscriber($this->params['id']);
$subscriber = new subscribers($this->params['id']);
// render the template
assign_to_template(array(
'subscriber'=>$subscriber,
'ealerts'=>$ealerts
));
} | Class | 2 |
foreach ($page as $pageperm) {
if (!empty($pageperm['manage'])) return true;
}
| Class | 2 |
public static function remove($var) {
unset($_SESSION['gxsess']['val'][$var]);
}
| Base | 1 |
function searchName() {
return gt("Calendar Event");
}
| Class | 2 |
public function show()
{
$task = $this->getTask();
$subtask = $this->getSubtask();
$this->response->html($this->template->render('subtask_converter/show', array(
'subtask' => $subtask,
'task' => $task,
)));
} | Base | 1 |
static function description() { return gt("Places navigation links/menus on the page."); }
| Class | 2 |
function insertObject($object, $table) {
//if ($table=="text") eDebug($object,true);
$sql = "INSERT INTO `" . $this->prefix . "$table` (";
$values = ") VALUES (";
foreach (get_object_vars($object) as $var => $val) {
//We do not want to save any fields that start with an '_'
if ($var{0} != '_') {
$sql .= "`$var`,";
if ($values != ") VALUES (") {
$values .= ",";
}
$values .= "'" . $this->escapeString($val) . "'";
}
}
$sql = substr($sql, 0, -1) . substr($values, 0) . ")";
//if($table=='text')eDebug($sql,true);
if (@mysqli_query($this->connection, $sql) != false) {
$id = mysqli_insert_id($this->connection);
return $id;
} else
return 0;
} | Base | 1 |
$bdd->exec($sql);
}
}
} | Base | 1 |
public static function BBCode2Html($text) {
$text = trim($text);
$text = self::parseEmoji($text);
// Smileys to find...
$in = array(
);
// And replace them by...
$out = array(
);
$in[] = '[/*]';
$in[] = '[*]';
$out[] = '</li>';
$out[] = '<li>';
$text = str_replace($in, $out, $text);
// BBCode to find...
$in = array( '/\[b\](.*?)\[\/b\]/ms',
'/\[i\](.*?)\[\/i\]/ms',
'/\[u\](.*?)\[\/u\]/ms',
'/\[mark\](.*?)\[\/mark\]/ms',
'/\[s\](.*?)\[\/s\]/ms',
'/\[list\=(.*?)\](.*?)\[\/list\]/ms',
'/\[list\](.*?)\[\/list\]/ms',
'/\[\*\]\s?(.*?)\n/ms',
'/\[fs(.*?)\](.*?)\[\/fs(.*?)\]/ms',
'/\[color\=(.*?)\](.*?)\[\/color\]/ms'
);
// And replace them by...
$out = array( '<strong>\1</strong>',
'<em>\1</em>',
'<u>\1</u>',
'<mark>\1</mark>',
'<strike>\1</strike>',
'<ol start="\1">\2</ol>',
'<ul>\1</ul>',
'<li>\1</li>',
'<span style="font-size:\1pt">\2</span>',
'<span style="color:#\1">\2</span>'
);
$text = preg_replace($in, $out, $text);
// Prepare quote's
$text = str_replace("\r\n","\n",$text);
// paragraphs
$text = str_replace("\r", "", $text);
$text = nl2br($text);
// clean some tags to remain strict
// not very elegant, but it works. No time to do better ;)
if (!function_exists('removeBr')) {
function removeBr($s) {
return str_replace("<br />", "", $s[0]);
}
}
$text = preg_replace_callback('/<pre>(.*?)<\/pre>/ms', "removeBr", $text);
$text = preg_replace('/<p><pre>(.*?)<\/pre><\/p>/ms', "<pre>\\1</pre>", $text);
$text = preg_replace_callback('/<ul>(.*?)<\/ul>/ms', "removeBr", $text);
$text = preg_replace('/<p><ul>(.*?)<\/ul><\/p>/ms', "<ul>\\1</ul>", $text);
return $text;
} | Base | 1 |
protected function getSubtask()
{
$subtask = $this->subtaskModel->getById($this->request->getIntegerParam('subtask_id'));
if (empty($subtask)) {
throw new PageNotFoundException();
}
return $subtask;
} | Base | 1 |
public function getAuthority()
{
if (empty($this->host)) {
return '';
}
$authority = $this->host;
if (!empty($this->userInfo)) {
$authority = $this->userInfo . '@' . $authority;
}
if ($this->isNonStandardPort($this->scheme, $this->host, $this->port)) {
$authority .= ':' . $this->port;
}
return $authority;
} | Base | 1 |
function selectObjectBySql($sql) {
//$logFile = "C:\\xampp\\htdocs\\supserg\\tmp\\queryLog.txt";
//$lfh = fopen($logFile, 'a');
//fwrite($lfh, $sql . "\n");
//fclose($lfh);
$res = @mysqli_query($this->connection, $this->injectProof($sql));
if ($res == null)
return null;
return mysqli_fetch_object($res);
} | Base | 1 |
$row_rub = sql_fetsel("id_rubrique", "spip_rubriques",
"lang='" . $GLOBALS['spip_lang'] . "' AND id_parent=$id_parent");
if ($row_rub) {
$row['id_rubrique'] = $row_rub['id_rubrique'];
}
}
}
}
return $row;
} | Base | 1 |
Subsets and Splits