code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$action = $this->actionModel->getById($this->request->getIntegerParam('action_id'));
if (! empty($action) && $this->actionModel->remove($action['id'])) {
$this->flash->success(t('Action removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this action.'));
}
$this->response->redirect($this->helper->url->to('ActionController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function saveconfig() {
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']);
$conf = serialize($calc->parseConfig($this->params));
$calc->update(array('config'=>$conf));
expHistory::back();
} | Base | 1 |
function selectObjectsBySql($sql) {
$res = @mysqli_query($this->connection, $sql);
if ($res == null)
return array();
$objects = array();
for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++)
$objects[] = mysqli_fetch_object($res);
return $objects;
} | Base | 1 |
public function saveconfig() {
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']);
$conf = serialize($calc->parseConfig($this->params));
$calc->update(array('config'=>$conf));
expHistory::back();
} | Base | 1 |
function lockTable($table,$lockType="WRITE") {
$sql = "LOCK TABLES `" . $this->prefix . "$table` $lockType";
$res = mysqli_query($this->connection, $sql);
return $res;
} | Base | 1 |
function get_plural_forms() {
// lets assume message number 0 is header
// this is true, right?
$this->load_tables();
// cache header field for plural forms
if (! is_string($this->pluralheader)) {
if ($this->enable_cache) {
$header = $this->cache_translations[""];
} else {
$header = $this->get_translation_string(0);
}
$expr = $this->extract_plural_forms_header_from_po_header($header);
$this->pluralheader = $this->sanitize_plural_expression($expr);
}
return $this->pluralheader;
} | Base | 1 |
public static function footer($vars=""){
global $GLOBALS;
if (isset($vars)) {
# code...
$GLOBALS['data'] = $vars;
self::theme('footer', $vars);
}else{
self::theme('footer');
}
}
| Base | 1 |
public function testVersion()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/version');
$result = json_decode($client->getResponse()->getContent(), true);
$this->assertIsArray($result);
$this->assertArrayHasKey('version', $result);
$this->assertArrayHasKey('versionId', $result);
$this->assertArrayHasKey('candidate', $result);
$this->assertArrayHasKey('semver', $result);
$this->assertArrayHasKey('name', $result);
$this->assertArrayHasKey('copyright', $result);
$this->assertSame(Constants::VERSION, $result['version']);
$this->assertSame(Constants::VERSION_ID, $result['versionId']);
$this->assertEquals(Constants::STATUS, $result['candidate']);
$this->assertEquals(Constants::VERSION . '-' . Constants::STATUS, $result['semver']);
$this->assertEquals(Constants::NAME, $result['name']);
$this->assertEquals(
'Kimai - ' . Constants::VERSION . ' ' . Constants::STATUS . ' (' . Constants::NAME . ') by Kevin Papst and contributors.',
$result['copyright']
);
} | Base | 1 |
private function getCriterionValue($value) {
if ($value instanceof \AbstractQuery) {
return $value->getQuery();
} else if ($value instanceof \QueryExpression) {
return $value->getValue();
} else if (DBmysql::isNameQuoted($value)) { //FIXME: database related
return $value;
} else if ($value instanceof \QueryParam) {
return $value->getValue();
} else {
return $this->analyseCriterionValue($value);
}
} | Base | 1 |
function barcode_encode($code,$encoding)
{
global $genbarcode_loc;
if (
((preg_match("/^ean$/i", $encoding)
&& ( strlen($code)==12 || strlen($code)==13)))
|| (($encoding) && (preg_match("/^isbn$/i", $encoding))
&& (( strlen($code)==9 || strlen($code)==10) ||
(((preg_match("/^978/", $code) && strlen($code)==12) ||
(strlen($code)==13)))))
|| (( !isset($encoding) || !$encoding || (preg_match("/^ANY$/i", $encoding) ))
&& (preg_match("/^[0-9]{12,13}$/", $code)))
)
{
/* use built-in EAN-Encoder */
dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean");
$bars=barcode_encode_ean($code, $encoding);
}
else if (file_exists($genbarcode_loc))
{
/* use genbarcode */
dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding);
$bars=barcode_encode_genbarcode($code, $encoding);
}
else
{
print "barcode_encode needs an external programm for encodings other then EAN/ISBN<BR>\n";
print "<UL>\n";
print "<LI>download gnu-barcode from <A href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
print "<LI>compile and install them\n";
print "<LI>download genbarcode from <A href=\"http://www.ashberg.de/bar/\">www.ashberg.de/bar/</A>\n";
print "<LI>compile and install them\n";
print "<LI>specify path the genbarcode in barcode module setup\n";
print "</UL>\n";
print "<BR>\n";
return false;
}
return $bars;
} | Class | 2 |
public function setMultiSectionSeparators( ?array $separators ) {
$this->multiSectionSeparators = (array)$separators ?? [];
} | 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),
));
}
| Base | 1 |
$masteroption->delete();
}
// delete the mastergroup
$db->delete('optiongroup', 'optiongroup_master_id='.$mastergroup->id);
$mastergroup->delete();
expHistory::back();
} | Base | 1 |
public function handle($request, Closure $next)
{
view()->share('cspNonce', $this->cspService->getNonce());
if ($this->cspService->allowedIFrameHostsConfigured()) {
config()->set('session.same_site', 'none');
}
$response = $next($request);
$this->cspService->setFrameAncestors($response);
$this->cspService->setScriptSrc($response);
$this->cspService->setObjectSrc($response);
$this->cspService->setBaseUri($response);
return $response;
} | Base | 1 |
public function manage_versions() {
expHistory::set('manageable', $this->params);
$hv = new help_version();
$current_version = $hv->find('first', 'is_current=1');
$sql = 'SELECT hv.*, COUNT(h.title) AS num_docs FROM '.DB_TABLE_PREFIX.'_help h ';
$sql .= 'RIGHT JOIN '.DB_TABLE_PREFIX.'_help_version hv ON h.help_version_id=hv.id GROUP BY hv.version';
$page = new expPaginator(array(
'sql'=>$sql,
'limit'=>30,
'order' => (isset($this->params['order']) ? $this->params['order'] : 'version'),
'dir' => (isset($this->params['dir']) ? $this->params['dir'] : 'DESC'),
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->baseclassname,
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'columns'=>array(
gt('Version')=>'version',
gt('Title')=>'title',
gt('Current')=>'is_current',
gt('# of Docs')=>'num_docs'
),
));
assign_to_template(array(
'current_version'=>$current_version,
'page'=>$page
));
} | Class | 2 |
$confirm = pack('H*', gps('confirm'));
$name = substr($confirm, 5);
$nonce = safe_field("nonce", 'txp_users', "name = '".doSlash($name)."'");
if ($nonce and $confirm === pack('H*', substr(md5($nonce), 0, 10)).$name) {
include_once txpath.'/lib/txplib_admin.php';
$message = reset_author_pass($name);
}
} | Base | 1 |
function update_vendor() {
$vendor = new vendor();
$vendor->update($this->params['vendor']);
expHistory::back();
} | Base | 1 |
public function getQuerySelect()
{
$R = 'R_' . $this->id;
return "$R.value_id AS `" . $this->name . "`";
} | Base | 1 |
public function getViewFileParams () {
if (!isset ($this->_viewFileParams)) {
$this->_viewFileParams = array_merge (
parent::getViewFileParams (),
array (
'chartType' => $this->chartType,
'chartSettingsDataProvider' => self::getChartSettingsProvider (
$this->chartType),
'eventTypes' =>
array ('all'=>Yii::t('app', 'All Events')) + Events::$eventLabels,
'socialSubtypes' => json_decode (
Dropdowns::model()->findByPk(113)->options,true),
'visibilityFilters' => array (
'1'=>'Public',
'0'=>'Private',
),
'suppressChartSettings' => false,
'chartType' => 'usersChart',
'widgetUID' => $this->widgetUID,
'metricTypes' => User::getUserOptions (),
)
);
}
return $this->_viewFileParams;
} | Class | 2 |
public function password()
{
$user = Auth::user();
return view('account/change-password', compact('user'));
} | Compound | 4 |
public static function validateServer($path, $values)
{
$result = array(
'Server' => '',
'Servers/1/user' => '',
'Servers/1/SignonSession' => '',
'Servers/1/SignonURL' => ''
);
$error = false;
if ($values['Servers/1/auth_type'] == 'config'
&& empty($values['Servers/1/user'])
) {
$result['Servers/1/user'] = __(
'Empty username while using [kbd]config[/kbd] authentication method!'
);
$error = true;
}
if ($values['Servers/1/auth_type'] == 'signon'
&& empty($values['Servers/1/SignonSession'])
) {
$result['Servers/1/SignonSession'] = __(
'Empty signon session name '
. 'while using [kbd]signon[/kbd] authentication method!'
);
$error = true;
}
if ($values['Servers/1/auth_type'] == 'signon'
&& empty($values['Servers/1/SignonURL'])
) {
$result['Servers/1/SignonURL'] = __(
'Empty signon URL while using [kbd]signon[/kbd] authentication '
. 'method!'
);
$error = true;
}
if (! $error && $values['Servers/1/auth_type'] == 'config') {
$password = $values['Servers/1/nopassword'] ? null
: $values['Servers/1/password'];
$test = static::testDBConnection(
$values['Servers/1/connect_type'],
$values['Servers/1/host'],
$values['Servers/1/port'],
$values['Servers/1/socket'],
$values['Servers/1/user'],
$password,
'Server'
);
if ($test !== true) {
$result = array_merge($result, $test);
}
}
return $result;
} | Class | 2 |
function logon($username, $password, &$sessionId)
{
global $_POST, $_COOKIE;
global $strUsernameOrPasswordWrong;
/**
* @todo Please check if the following statement is in correct place because
* it seems illogical that user can get session ID from internal login with
* a bad username or password.
*/
if (!$this->_verifyUsernameAndPasswordLength($username, $password)) {
return false;
}
$_POST['username'] = $username;
$_POST['password'] = $password;
$_POST['login'] = 'Login';
$_COOKIE['sessionID'] = uniqid('phpads', 1);
$_POST['phpAds_cookiecheck'] = $_COOKIE['sessionID'];
$this->preInitSession();
if ($this->_internalLogin($username, $password)) {
// Check if the user has administrator access to Openads.
if (OA_Permission::isUserLinkedToAdmin()) {
$this->postInitSession();
$sessionId = $_COOKIE['sessionID'];
return true;
} else {
$this->raiseError('User must be OA installation admin');
return false;
}
} else {
$this->raiseError($strUsernameOrPasswordWrong);
return false;
}
} | Compound | 4 |
function output( $p_format = 'dot', $p_headers = false ) {
# Check if it is a recognized format.
if( !isset( $this->formats[$p_format] ) ) {
trigger_error( ERROR_GENERIC, ERROR );
}
$t_binary = $this->formats[$p_format]['binary'];
$t_type = $this->formats[$p_format]['type'];
$t_mime = $this->formats[$p_format]['mime'];
# Send Content-Type header, if requested.
if( $p_headers ) {
header( 'Content-Type: ' . $t_mime );
}
# Retrieve the source dot document into a buffer
ob_start();
$this->generate();
$t_dot_source = ob_get_contents();
ob_end_clean();
# Start dot process
$t_command = $this->graphviz_tool . ' -T' . $p_format;
$t_descriptors = array(
0 => array( 'pipe', 'r', ),
1 => array( 'pipe', 'w', ),
2 => array( 'file', 'php://stderr', 'w', ),
);
$t_pipes = array();
$t_process = proc_open( $t_command, $t_descriptors, $t_pipes );
if( is_resource( $t_process ) ) {
# Filter generated output through dot
fwrite( $t_pipes[0], $t_dot_source );
fclose( $t_pipes[0] );
if( $p_headers ) {
# Headers were requested, use another output buffer to
# retrieve the size for Content-Length.
ob_start();
while( !feof( $t_pipes[1] ) ) {
echo fgets( $t_pipes[1], 1024 );
}
header( 'Content-Length: ' . ob_get_length() );
ob_end_flush();
} else {
# No need for headers, send output directly.
while( !feof( $t_pipes[1] ) ) {
print( fgets( $t_pipes[1], 1024 ) );
}
}
fclose( $t_pipes[1] );
proc_close( $t_process );
}
} | Base | 1 |
public function testPinCommentAction()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$this->assertAccessIsGranted($client, '/admin/project/1/details');
$form = $client->getCrawler()->filter('form[name=project_comment_form]')->form();
$client->submit($form, [
'project_comment_form' => [
'message' => 'Foo bar blub',
]
]);
$this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text');
self::assertStringContainsString('Foo bar blub', $node->html());
$node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');
self::assertEquals(0, $node->count());
$comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll();
$id = $comments[0]->getId();
$this->request($client, '/admin/project/' . $id . '/comment_pin');
$this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));
$client->followRedirect();
$node = $client->getCrawler()->filter('div.box#comments_box .box-body a.btn.active');
self::assertEquals(1, $node->count());
self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_pin'), $node->attr('href'));
} | Compound | 4 |
function edit_option_master() {
expHistory::set('editable', $this->params);
$params = isset($this->params['id']) ? $this->params['id'] : $this->params;
$record = new option_master($params);
assign_to_template(array(
'record'=>$record
));
} | Class | 2 |
public function backup($type='json')
{
global $DB;
global $website;
$DB->query('SELECT * FROM nv_shipping_methods WHERE website = '.protect($website->id), 'object');
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
public function upload() {
// upload the file, but don't save the record yet...
if ($this->params['resize'] != 'false') {
$maxwidth = $this->params['max_width'];
} else {
$maxwidth = null;
}
$file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth);
// since most likely this function will only get hit via flash in YUI Uploader
// and since Flash can't pass cookies, we lose the knowledge of our $user
// so we're passing the user's ID in as $_POST data. We then instantiate a new $user,
// and then assign $user->id to $file->poster so we have an audit trail for the upload
if (is_object($file)) {
$resized = !empty($file->resized) ? true : false;
$user = new user($this->params['usrid']);
$file->poster = $user->id;
$file->posted = $file->last_accessed = time();
$file->save();
if (!empty($this->params['cat'])) {
$expcat = new expCat($this->params['cat']);
$params['expCat'][0] = $expcat->id;
$file->update($params);
}
// a echo so YUI Uploader is notified of the function's completion
if ($resized) {
echo gt('File resized and then saved');
} else {
echo gt('File saved');
}
} else {
echo gt('File was NOT uploaded!');
// flash('error',gt('File was not uploaded!'));
}
} | Class | 2 |
function __construct(Frame $frame, Dompdf $dompdf)
{
parent::__construct($frame, $dompdf);
$url = $frame->get_node()->getAttribute("src");
$debug_png = $dompdf->getOptions()->getDebugPng();
if ($debug_png) {
print '[__construct ' . $url . ']';
}
list($this->_image_url, /*$type*/, $this->_image_msg) = Cache::resolve_url(
$url,
$dompdf->getProtocol(),
$dompdf->getBaseHost(),
$dompdf->getBasePath(),
$dompdf
);
if (Cache::is_broken($this->_image_url) &&
$alt = $frame->get_node()->getAttribute("alt")
) {
$fontMetrics = $dompdf->getFontMetrics();
$style = $frame->get_style();
$font = $style->font_family;
$size = $style->font_size;
$word_spacing = $style->word_spacing;
$letter_spacing = $style->letter_spacing;
$style->width = (4 / 3) * $fontMetrics->getTextWidth($alt, $font, $size, $word_spacing, $letter_spacing);
$style->height = $fontMetrics->getFontHeight($font, $size);
}
} | Base | 1 |
function db_properties($table)
{
global $DatabaseType, $DatabaseUsername;
switch ($DatabaseType) {
case 'mysqli':
$result = DBQuery("SHOW COLUMNS FROM $table");
while ($row = db_fetch_row($result)) {
$properties[strtoupper($row['FIELD'])]['TYPE'] = strtoupper($row['TYPE'], strpos($row['TYPE'], '('));
if (!$pos = strpos($row['TYPE'], ','))
$pos = strpos($row['TYPE'], ')');
else
$properties[strtoupper($row['FIELD'])]['SCALE'] = substr($row['TYPE'], $pos + 1);
$properties[strtoupper($row['FIELD'])]['SIZE'] = substr($row['TYPE'], strpos($row['TYPE'], '(') + 1, $pos);
if ($row['NULL'] != '')
$properties[strtoupper($row['FIELD'])]['NULL'] = "Y";
else
$properties[strtoupper($row['FIELD'])]['NULL'] = "N";
}
break;
}
return $properties;
} | Base | 1 |
public function 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 |
$_ret[$_k] = $this->convEnc($_v, $from, $to, '', false, $unknown = '_');
}
$var = $_ret;
} else {
$_var = false;
if (is_string($var)) {
$_var = $var;
if (false !== ($_var = @iconv($from, $to.'//TRANSLIT', $_var))) {
$_var = str_replace('?', $unknown, $_var);
}
}
if ($_var !== false) {
$var = $_var;
}
}
if ($restoreLocale) {
setlocale(LC_ALL, elFinder::$locale);
}
}
return $var;
} | Base | 1 |
$content = ($vars['excerpt'])? substr(
strip_tags(
Typo::Xclean($p->content)
), 0, $excerptMax): "";
echo "<li class=\"".$liClass."\">
<h4 class=\"".$h4Class."\"><a href=\"".Url::post($p->id)."\">{$p->title}</a></h4>
<p class=\"".$pClass."\">".$content."</p>
</li>";
}
| Base | 1 |
public function getFilePath($fileName = null)
{
if ($fileName === null) {
$fileName = $this->fileName;
}
return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
} | Base | 1 |
public function approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for note to approve'));
$lastUrl = expHistory::getLast('editable');
}
$simplenote = new expSimpleNote($this->params['id']);
assign_to_template(array(
'simplenote'=>$simplenote,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'tab'=>$this->params['tab']
));
} | Class | 2 |
function sell_media_ecommerce_enabled( $post_id ) {
$status = true;
$meta = get_post_meta( $post_id, 'sell_media_enable_ecommerce', true );
if ( class_exists( 'VS_Platform' ) && 0 === $meta ) {
$status = false;
}
return $status;
} | Base | 1 |
$link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));
| Base | 1 |
public function getLatestRevisions()
{
if (! $this->latest_revisions) {
$pm = ProjectManager::instance();
$project = $pm->getProject($this->group_id);
if ($project && $this->canBeUsedByProject($project)) {
list($this->latest_revisions,) = svn_get_revisions($project, 0, 5, '', '', '', '', 0, false);
}
}
return $this->latest_revisions;
} | Base | 1 |
public function testNameExceptionPhp53()
{
if (PHP_VERSION_ID >= 50400) {
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
$this->proxy->setActive(true);
$this->proxy->setName('foo');
} | Base | 1 |
protected static function localScandir($dir) {
// PHP function scandir() is not work well in specific environment. I dont know why.
// ref. https://github.com/Studio-42/elFinder/issues/1248
$files = array();
if ($dh = opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if ($file !== '.' && $file !== '..') {
$files[] = $file;
}
}
closedir($dh);
} else {
$this->setError('Can not open local directory.');
}
return $files;
} | 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'])));
} | Class | 2 |
function show_vendor () {
$vendor = new vendor();
if(isset($this->params['id'])) {
$vendor = $vendor->find('first', 'id =' .$this->params['id']);
$vendor_title = $vendor->title;
$state = new geoRegion($vendor->state);
$vendor->state = $state->name;
//Removed unnecessary fields
unset(
$vendor->title,
$vendor->table,
$vendor->tablename,
$vendor->classname,
$vendor->identifier
);
assign_to_template(array(
'vendor_title' => $vendor_title,
'vendor'=>$vendor
));
}
} | Class | 2 |
public static function getModelTypes($assoc = false) {
$modelTypes = Yii::app()->db->createCommand()
->selectDistinct('modelName')
->from('x2_fields')
->where('modelName!="Calendar"')
->order('modelName ASC')
->queryColumn();
if ($assoc === true) {
return array_combine($modelTypes, array_map(function($term) {
return Yii::t('app', X2Model::getModelTitle($term));
}, $modelTypes));
}
$modelTypes = array_map(function($term) {
return Yii::t('app', $term);
}, $modelTypes);
return $modelTypes;
} | Base | 1 |
$file = sprintf('%s/%s.class.php', $path, $class_name);
if(is_file($file))
{
include_once $file;
}
}
}
| Base | 1 |
function update_option_master() {
global $db;
$id = empty($this->params['id']) ? null : $this->params['id'];
$opt = new option_master($id);
$oldtitle = $opt->title;
$opt->update($this->params);
// if the title of the master changed we should update the option groups that are already using it.
if ($oldtitle != $opt->title) {
}$db->sql('UPDATE '.$db->prefix.'option SET title="'.$opt->title.'" WHERE option_master_id='.$opt->id);
expHistory::back();
} | Class | 2 |
function manage () {
expHistory::set('viewable', $this->params);
$vendor = new vendor();
$vendors = $vendor->find('all');
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');
}
assign_to_template(array(
'purchase_orders'=>$purchase_orders,
'vendors' => $vendors,
'vendor_id' => @$this->params['vendor']
));
} | Base | 1 |
public function sdm_save_upload_meta_data($post_id) { // Save File Upload metabox
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
if (!isset($_POST['sdm_upload_box_nonce_check']) || !wp_verify_nonce($_POST['sdm_upload_box_nonce_check'], 'sdm_upload_box_nonce'))
return;
if (isset($_POST['sdm_upload'])) {
update_post_meta($post_id, 'sdm_upload', $_POST['sdm_upload']);
}
} | Base | 1 |
->first(function (User $user) {
return $user->getPreference('blocksPd', false);
}) !== null; | Class | 2 |
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 static function getHelpVersionId($version) {
global $db;
return $db->selectValue('help_version', 'id', 'version="'.$version.'"');
} | Class | 2 |
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 fixName($name) {
$name = preg_replace('/[^A-Za-z0-9\.]/','_',$name);
if ($name[0] == '.')
$name[0] = '_';
return $name;
// return preg_replace('/[^A-Za-z0-9\.]/', '-', $name);
} | Class | 2 |
protected function fsock_get_contents(&$url, $timeout, $redirect_max, $ua, $outfp)
{
$connect_timeout = 3;
$connect_try = 3;
$method = 'GET';
$readsize = 4096;
$ssl = '';
$getSize = null;
$headers = '';
$arr = parse_url($url);
if (!$arr) {
// Bad request
return false;
}
if ($arr['scheme'] === 'https') {
$ssl = 'ssl://';
}
// query
$arr['query'] = isset($arr['query']) ? '?' . $arr['query'] : '';
// port
$port = isset($arr['port']) ? $arr['port'] : '';
$arr['port'] = $port ? $port : ($ssl ? 443 : 80);
$url_base = $arr['scheme'] . '://' . $arr['host'] . ($port ? (':' . $port) : ''); | Base | 1 |
public function testInfoWithoutUrl()
{
$this->assertRequestIsRedirect('info');
} | Base | 1 |
public function start()
{
if ($this->started) {
return true;
}
if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) {
throw new \RuntimeException('Failed to start the session: already started by PHP.');
}
if (PHP_VERSION_ID < 50400 && !$this->closed && isset($_SESSION) && session_id()) {
// not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3
throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
}
if (ini_get('session.use_cookies') && headers_sent($file, $line)) {
throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line));
}
// ok to try and start the session
if (!session_start()) {
throw new \RuntimeException('Failed to start the session');
}
$this->loadSession();
if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) {
// This condition matches only PHP 5.3 with internal save handlers
$this->saveHandler->setActive(true);
}
return true;
} | Base | 1 |
function db_start()
{
global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType;
switch ($DatabaseType) {
case 'mysqli':
$connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort);
break;
}
// Error code for both.
if ($connection === false) {
switch ($DatabaseType) {
case 'mysqli':
$errormessage = mysqli_error($connection);
break;
}
db_show_error("", "" . _couldNotConnectToDatabase . ": $DatabaseServer", $errormessage);
}
return $connection;
} | Base | 1 |
public static function initializeNavigation() {
$sections = section::levelTemplate(0, 0);
return $sections;
}
| Class | 2 |
function searchName() {
return gt("Calendar Event");
}
| Base | 1 |
public function backup($type='json')
{
global $DB;
global $website;
$out = array();
$DB->query('
SELECT * FROM nv_webdictionary_history
WHERE website = '.protect($website->id),
'object'
);
if($type='json')
$out = json_encode($DB->result());
return $out;
}
| 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 local($date, $format=''){
setlocale(LC_TIME, Options::v('country_id'));
(empty($format))? $format = "%#d %B %Y %H:%M %p" : $format = $format;
$timezone = Options::v('timezone');
$date = new DateTime($date);
$date->setTimezone(new DateTimeZone($timezone));
$newdate = $date->format("Y/m/j H:i:s");
$newdate = strftime($format, strtotime($newdate));
return $newdate." ".$date->format("T");
}
| Base | 1 |
public static function getHelpVersionId($version) {
global $db;
return $db->selectValue('help_version', 'id', 'version="'.$version.'"');
} | Base | 1 |
public function getFileContent($file, $identifier)
{
$resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
$this->process->execute($resource, $content, $this->repoDir);
if (!trim($content)) {
return null;
}
return $content;
} | Base | 1 |
public function getQueryOrderby()
{
return $this->getBind()->getQueryOrderby();
} | Base | 1 |
public function getQuerySelect()
{
return '';
} | Base | 1 |
public function rename($hash, $name) {
if ($this->commandDisabled('rename')) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
if (!$this->nameAccepted($name)) {
return $this->setError(elFinder::ERROR_INVALID_NAME, $name);
}
$mimeByName = elFinderVolumeDriver::mimetypeInternalDetect($name);
if ($mimeByName && $mimeByName !== 'unknown' && !$this->allowPutMime($mimeByName)) {
return $this->setError(elFinder::ERROR_INVALID_NAME, $name);
}
if (!($file = $this->file($hash))) {
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
}
if ($name == $file['name']) {
return $file;
}
if (!empty($file['locked'])) {
return $this->setError(elFinder::ERROR_LOCKED, $file['name']);
}
$path = $this->decode($hash);
$dir = $this->dirnameCE($path);
$stat = $this->stat($this->joinPathCE($dir, $name));
if ($stat) {
return $this->setError(elFinder::ERROR_EXISTS, $name);
}
if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
return $this->setError(elFinder::ERROR_PERM_DENIED);
}
$this->rmTmb($file); // remove old name tmbs, we cannot do this after dir move
if ($path = $this->convEncOut($this->_move($this->convEncIn($path), $this->convEncIn($dir), $this->convEncIn($name)))) {
$this->clearcache();
return $this->stat($path);
}
return false;
} | 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 |
$this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);
} | Class | 2 |
protected function signDocument(\DOMDocument $document, $node)
{
$this->add509Cert($this->getCertificate()->getPublicKey()->getX509Certificate());
$this->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
$this->addReference($document->documentElement, XMLSecurityDSig::SHA1, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), array('id_name' => 'ID'));
$this->sign($this->getCertificate()->getPrivateKey());
$this->insertSignature($document->firstChild, $node);
$this->canonicalizeSignedInfo();
} | Base | 1 |
public function IsQmail() {
if (stristr(ini_get('sendmail_path'), 'qmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
} | Class | 2 |
public function testGetEvents(){
TestingAuxLib::loadX2NonWebUser ();
TestingAuxLib::suLogin ('admin');
Yii::app()->settings->historyPrivacy = null;
$lastEventId = 0;
$lastTimestamp = 0;
$events = Events::getEvents ($lastEventId, $lastTimestamp, 4);
$this->assertEquals (
Yii::app()->db->createCommand (
"select id from x2_events order by timestamp desc, id desc limit 4")
->queryColumn (),
array_map(function ($event) { return $event->id; }, $events['events'])
);
TestingAuxLib::restoreX2WebUser ();
} | Class | 2 |
public static function pathFile($path, $file=false)
{
if($file!==false){
$fullPath = $path.$file;
}
else {
$fullPath = $path;
}
// Fix for Windows on paths. eg: $path = c:\diego/page/subpage convert to c:\diego\page\subpages
$fullPath = str_replace('/', DS, $fullPath);
if(CHECK_SYMBOLIC_LINKS) {
$real = realpath($fullPath);
}
else {
$real = file_exists($fullPath)?$fullPath:false;
}
// If $real is FALSE the file does not exist.
if($real===false) {
return false;
}
// If the $real path does not start with the systemPath then this is Path Traversal.
if(strpos($fullPath, $real)!==0) {
return false;
}
return true;
} | Base | 1 |
public static function DragnDropReRank2() {
global $router, $db;
$id = $router->params['id'];
$page = new section($id);
$old_rank = $page->rank;
$old_parent = $page->parent;
$new_rank = $router->params['position'] + 1; // rank
$new_parent = intval($router->params['parent']);
$db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole
$db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room
$params = array();
$params['parent'] = $new_parent;
$params['rank'] = $new_rank;
$page->update($params);
self::checkForSectionalAdmins($id);
expSession::clearAllUsersSessionCache('navigation');
}
| Base | 1 |
$emails[$u->email] = trim(user::getUserAttribution($u->id));
}
| Class | 2 |
print_r($single_error);
}
echo '</pre>';
} | Class | 2 |
public function addGroupBy( $groupBy ) {
if ( empty( $groupBy ) ) {
throw new \MWException( __METHOD__ . ': An empty group by clause was passed.' );
}
$this->groupBy[] = $groupBy;
return true;
} | Class | 2 |
$this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);
} | Base | 1 |
static function isSearchable() {
return true;
}
| Base | 1 |
public function backup($type='json')
{
global $DB;
global $website;
$DB->query('
SELECT *
FROM nv_blocks
WHERE website = '.protect($website->id),
'object'
);
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
public static function fixName($name) {
$name = preg_replace('/[^A-Za-z0-9\.]/','_',$name);
if ($name[0] == '.')
$name[0] = '_';
return $name;
// return preg_replace('/[^A-Za-z0-9\.]/', '-', $name);
} | Base | 1 |
public function testCompilePathIsProperlyCreated()
{
$compiler = new BladeCompiler($this->getFiles(), __DIR__);
$this->assertEquals(__DIR__.'/'.sha1('foo').'.php', $compiler->getCompiledPath('foo'));
} | Class | 2 |
foreach ($days as $value) {
$regitem[] = $value;
}
| Base | 1 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Base | 1 |
foreach ($allowedFolders as $folder) {
if ('/' . $folder === substr($uri, 0, 1 + strlen($folder))) {
header('Content-Type: ' . $this->getMime($filePath));
readfile($filePath);
return true;
}
} | Base | 1 |
private function load($id)
{
global $zdb;
try {
$select = $zdb->select(self::TABLE);
$select->limit(1)
->where(self::PK . ' = ' . $id);
$results = $zdb->execute($select);
$this->loadFromRs($results->current());
} catch (Throwable $e) {
Analog::log(
'An error occurred loading reminder #' . $id . "Message:\n" .
$e->getMessage(),
Analog::ERROR
);
throw $e;
}
} | Base | 1 |
function update_option_master() {
global $db;
$id = empty($this->params['id']) ? null : $this->params['id'];
$opt = new option_master($id);
$oldtitle = $opt->title;
$opt->update($this->params);
// if the title of the master changed we should update the option groups that are already using it.
if ($oldtitle != $opt->title) {
}$db->sql('UPDATE '.$db->prefix.'option SET title="'.$opt->title.'" WHERE option_master_id='.$opt->id);
expHistory::back();
} | Base | 1 |
public function getTrustedProxyData()
{
return array(
array(array(), array('127.0.0.1')),
array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')),
array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')),
);
} | Class | 2 |
$count += $db->dropTable($basename);
}
flash('message', gt('Deleted').' '.$count.' '.gt('unused tables').'.');
expHistory::back();
} | Base | 1 |
public function getMailingDetails($id)
{
trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be private with 5.8.', __CLASS__, __METHOD__), E_USER_DEPRECATED);
$details = Shopware()->Modules()->Marketing()->sMailCampaignsGetDetail((int) $id);
foreach ($details['containers'] as $key => $container) {
if ($container['type'] === 'ctVoucher') {
if (!empty($container['value'])) {
$details['voucher'] = $container['value'];
}
$details['containers'][$key]['type'] = 'ctText';
}
if ($container['type'] === 'ctSuggest') {
$details['suggest'] = true;
}
}
return $details;
} | Base | 1 |
public function backup($type='json')
{
global $DB;
global $website;
$DB->query('SELECT * FROM nv_orders WHERE website = '.protect($website->id), 'object');
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
public function testValidatesUriCanBeParsed()
{
new Uri('///');
} | Base | 1 |
$rst[$key] = self::parseAndTrim($st, $unescape);
}
return $rst;
}
$str = str_replace("<br>"," ",$str);
$str = str_replace("</br>"," ",$str);
$str = str_replace("<br/>"," ",$str);
$str = str_replace("<br />"," ",$str);
$str = str_replace("\r\n"," ",$str);
$str = str_replace('"',""",$str);
$str = str_replace("'","'",$str);
$str = str_replace("’","’",$str);
$str = str_replace("‘","‘",$str);
$str = str_replace("®","®",$str);
$str = str_replace("–","-", $str);
$str = 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 = trim($str);
if ($unescape) {
$str = stripcslashes($str);
} else {
$str = addslashes($str);
}
return $str;
} | Base | 1 |
public function showall() {
global $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(
'sections' => $navsections,
'current' => $current,
'canManage' => ((isset($user->is_acting_admin) && $user->is_acting_admin == 1) ? 1 : 0),
));
}
| Base | 1 |
self::assertSame($shouldBePresent, $request->hasHeader('Authorization'));
self::assertSame($shouldBePresent, $request->hasHeader('Cookie'));
return new Response(200);
}
]); | Class | 2 |
private function normalize($str, $opts) {
if ($opts['nfc'] || $opts['nfkc']) {
if (class_exists('Normalizer', false)) {
if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
$str = Normalizer::normalize($str, Normalizer::FORM_C);
if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
$str = Normalizer::normalize($str, Normalizer::FORM_KC);
} else {
if (! class_exists('I18N_UnicodeNormalizer', false)) {
@ include_once 'I18N/UnicodeNormalizer.php';
}
if (class_exists('I18N_UnicodeNormalizer', false)) {
$normalizer = new I18N_UnicodeNormalizer();
if ($opts['nfc'])
$str = $normalizer->normalize($str, 'NFC');
if ($opts['nfkc'])
$str = $normalizer->normalize($str, 'NFKC');
}
}
}
if ($opts['lowercase']) {
$str = strtolower($str);
}
if ($opts['convmap'] && is_array($opts['convmap'])) {
$str = strtr($str, $opts['convmap']);
}
return $str;
} | Base | 1 |
public function update()
{
global $DB;
global $events;
if(!is_array($this->categories))
$this->categories = array();
$ok = $DB->execute('
UPDATE nv_feeds
SET categories = :categories, format = :format, image = :image, entries = :entries,
content = :content, views = :views, permission = :permission, enabled = :enabled
WHERE id = :id AND website = :website',
array(
'id' => $this->id,
'website' => $this->website,
'categories' => implode(',', $this->categories),
'format' => $this->format,
'image' => value_or_default($this->image, 0),
'entries' => value_or_default($this->entries, 10),
'content' => $this->content,
'views' => value_or_default($this->views, 0),
'permission' => value_or_default($this->permission, 0),
'enabled' => value_or_default($this->enabled, 0)
)
);
if(!$ok)
throw new Exception($DB->get_last_error());
webdictionary::save_element_strings('feed', $this->id, $this->dictionary);
path::saveElementPaths('feed', $this->id, $this->paths);
if(method_exists($events, 'trigger'))
{
$events->trigger(
'feed',
'save',
array(
'feed' => $this
)
);
}
return true;
}
| Base | 1 |
private function deleteDir($dirPath)
{
if (!is_dir($dirPath)) {
$success = unlink($dirPath);
} else {
$success = true;
foreach (array_reverse(elFinderVolumeFTP::listFilesInDirectory($dirPath, false)) as $path) {
$path = $dirPath . DIRECTORY_SEPARATOR . $path;
if(is_link($path)) {
unlink($path);
} else if (is_dir($path)) {
$success = rmdir($path);
} else {
$success = unlink($path);
}
if (!$success) {
break;
}
}
if($success) {
$success = rmdir($dirPath);
}
}
if(!$success) {
$this->setError(elFinder::ERROR_RM, $dirPath);
return false;
}
return $success;
} | Base | 1 |
private function initData() {
$this->Set('customer', 0, true, true);
$this->Set('admin', 1, true, true);
$this->Set('subject', '', true, true);
$this->Set('category', '0', true, true);
$this->Set('priority', '2', true, true);
$this->Set('message', '', true, true);
$this->Set('dt', 0, true, true);
$this->Set('lastchange', 0, true, true);
$this->Set('ip', '', true, true);
$this->Set('status', '0', true, true);
$this->Set('lastreplier', '0', true, true);
$this->Set('by', '0', true, true);
$this->Set('answerto', '0', true, true);
$this->Set('archived', '0', true, true);
} | Class | 2 |
function edit_option_master() {
expHistory::set('editable', $this->params);
$params = isset($this->params['id']) ? $this->params['id'] : $this->params;
$record = new option_master($params);
assign_to_template(array(
'record'=>$record
));
} | Base | 1 |
function draw_cdef_preview($cdef_id) {
?>
<tr class='even'>
<td style='padding:4px'>
<pre>cdef=<?php print get_cdef($cdef_id, true);?></pre>
</td>
</tr>
<?php
} | Base | 1 |
public function testGetConfigWithBrokenSystem() {
$slideshow = true;
$exceptionMessage = 'Aïe!';
$this->configService->expects($this->any())
->method('getFeaturesList')
->willThrowException(new ServiceException($exceptionMessage));
// Default status code when something breaks
$status = Http::STATUS_INTERNAL_SERVER_ERROR;
$errorMessage = [
'message' => $exceptionMessage . ' (' . $status . ')',
'success' => false
];
/** @type JSONResponse $response */
$response = $this->controller->get($slideshow);
$this->assertEquals($errorMessage, $response->getData());
} | Base | 1 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.