code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
public function getSupportedBrands()
{
return array(
static::BRAND_VISA => '/^4\d{12}(\d{3})?$/',
static::BRAND_MASTERCARD => '/^(5[1-5]\d{4}|677189)\d{10}$/',
static::BRAND_DISCOVER => '/^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/',
static::BRAND_AMEX => '/^3[47]\d{13}$/',
static::BRAND_DINERS_CLUB => '/^3(0[0-5]|[68]\d)\d{11}$/',
static::BRAND_JCB => '/^35(28|29|[3-8]\d)\d{12}$/',
static::BRAND_SWITCH => '/^6759\d{12}(\d{2,3})?$/',
static::BRAND_SOLO => '/^6767\d{12}(\d{2,3})?$/',
static::BRAND_DANKORT => '/^5019\d{12}$/',
static::BRAND_MAESTRO => '/^(5[06-8]|6\d)\d{10,17}$/',
static::BRAND_FORBRUGSFORENINGEN => '/^600722\d{10}$/',
static::BRAND_LASER => '/^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/',
);
} | Base | 1 |
function singleQuoteReplace($param1 = false, $param2 = false, $param3)
{
return str_replace("'", "''", str_replace("\'", "'", $param3));
} | 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'])));
} | Class | 2 |
function render_menu_tabs()
{
$current_tab = $this->get_current_tab();
echo '<h2 class="nav-tab-wrapper">';
foreach ( $this->menu_tabs as $tab_key => $tab_caption )
{
$active = $current_tab == $tab_key ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->menu_page_slug . '&tab=' . $tab_key . '">' . $tab_caption . '</a>';
}
echo '</h2>';
}
| Base | 1 |
public function setContainer($container)
{
$this->container = $container;
$container->setType('ctBanner');
} | Base | 1 |
public function refreshUser(UserInterface $user)
{
$user = $this->inner->refreshUser($user);
$alterUser = \Closure::bind(function (InMemoryUser $user) { $user->password = 'foo'; }, null, class_exists(User::class) ? User::class : InMemoryUser::class);
$alterUser($user);
return $user;
} | Compound | 4 |
private function getTaskLink()
{
$link = $this->taskLinkModel->getById($this->request->getIntegerParam('link_id'));
if (empty($link)) {
throw new PageNotFoundException();
}
return $link;
} | Class | 2 |
public function confirm()
{
$task = $this->getTask();
$link_id = $this->request->getIntegerParam('link_id');
$link = $this->taskExternalLinkModel->getById($link_id);
if (empty($link)) {
throw new PageNotFoundException();
}
$this->response->html($this->template->render('task_external_link/remove', array(
'link' => $link,
'task' => $task,
)));
} | Base | 1 |
public function configure() {
$this->config['defaultbanner'] = array();
if (!empty($this->config['defaultbanner_id'])) {
$this->config['defaultbanner'][] = new expFile($this->config['defaultbanner_id']);
}
parent::configure();
$banners = $this->banner->find('all', null, 'companies_id');
assign_to_template(array(
'banners'=>$banners,
'title'=>static::displayname()
));
} | 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 static function getIconName($module)
{
return isset(static::$iconNames[$module])
? static::$iconNames[$module]
: strtolower(str_replace('_', '-', $module));
} | Base | 1 |
protected function imageExtensions()
{
return [
'jpg',
'jpeg',
'bmp',
'png',
'webp',
'gif',
'svg'
];
} | Base | 1 |
public static function editParam($param, $value, $post_id) {
$sql = "UPDATE `posts_param` SET `value` = '{$value}' WHERE `post_id` = '{$post_id}' AND `param` = '{$param}' ";
$q = Db::query($sql);
if ($q) {
return true;
}else{
return false;
}
}
| Base | 1 |
protected function fixupImportedAttributes($modelName, X2Model &$model) {
if ($modelName === 'Contacts' || $modelName === 'X2Leads')
$this->fixupImportedContactName ($model);
if ($modelName === 'Actions' && isset($model->associationType))
$this->reconstructImportedActionAssoc($model);
if ($model->hasAttribute('visibility')) {
// Nobody every remembers to set visibility... set it for them
if(empty($model->visibility) && ($model->visibility !== 0 && $model->visibility !== "0")
|| $model->visibility == 'Public') {
$model->visibility = 1;
} elseif($model->visibility == 'Private')
$model->visibility = 0;
}
// If date fields were provided, do not create new values for them
if (!empty($model->createDate) || !empty($model->lastUpdated) ||
!empty($model->lastActivity)) {
$now = time();
if (empty($model->createDate))
$model->createDate = $now;
if (empty($model->lastUpdated))
$model->lastUpdated = $now;
if ($model->hasAttribute('lastActivity') && empty($model->lastActivity))
$model->lastActivity = $now;
}
if($_SESSION['leadRouting'] == 1){
$assignee = $this->getNextAssignee();
if($assignee == "Anyone")
$assignee = "";
$model->assignedTo = $assignee;
}
// Loop through our override and set the manual data
foreach($_SESSION['override'] as $attr => $val){
$model->$attr = $val;
}
} | Class | 2 |
public static function getIconName($module)
{
return isset(static::$iconNames[$module])
? static::$iconNames[$module]
: strtolower(str_replace('_', '-', $module));
} | Class | 2 |
public function actionGetItems(){
$sql = 'SELECT id, name as value, subject FROM x2_bug_reports WHERE name LIKE :qterm ORDER BY name ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = $_GET['term'].'%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result); exit;
} | Class | 2 |
public function attorn(){
$login_user = $this->checkLogin();
$username = I("username");
$item_id = I("item_id/d");
$password = I("password");
$item = D("Item")->where("item_id = '$item_id' ")->find();
if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
$this->sendError(10303);
return ;
}
if(! D("User")-> checkLogin($item['username'],$password)){
$this->sendError(10208);
return ;
}
$member = D("User")->where(" username = '%s' ",array($username))->find();
if (!$member) {
$this->sendError(10209);
return ;
}
$data['username'] = $member['username'] ;
$data['uid'] = $member['uid'] ;
$id = D("Item")->where(" item_id = '$item_id' ")->save($data);
$return = D("Item")->where("item_id = '$item_id' ")->find();
if (!$return) {
$this->sendError(10101);
}
$this->sendResult($return);
} | Compound | 4 |
private function initProfileFieldFilter(ProfileField $profileField, $sortOrder = 1000)
{
$profileFieldType = $profileField->getFieldType();
if (!$profileFieldType) {
return;
}
$definition = $profileFieldType->getFieldFormDefinition();
$fieldType = isset($definition[$profileField->internal_name]['type']) ? $definition[$profileField->internal_name]['type'] : null;
$filterData = [
'title' => Yii::t($profileField->getTranslationCategory(), $profileField->title),
'type' => $fieldType,
'sortOrder' => $sortOrder,
];
switch ($fieldType) {
case 'text':
$filterData['type'] = 'widget';
$filterData['widget'] = PeopleFilterPicker::class;
$filterData['widgetOptions'] = [
'itemKey' => $profileField->internal_name
];
break;
case 'dropdownlist':
$filterData['options'] = array_merge(['' => Yii::t('UserModule.base', 'Any')], $definition[$profileField->internal_name]['items']);
break;
default:
// Skip not supported type
return;
}
$this->addFilter('fields[' . $profileField->internal_name . ']', $filterData);
} | 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;
}
}
}
| Base | 1 |
public function execute(&$params){
$options = &$this->config['options'];
$event = new Events;
$notif = new Notification;
$user = $this->parseOption('user', $params);
$type = $this->parseOption('type', $params);
if($type === 'auto'){
if(!isset($params['model']))
return array (false, '');
$notif->modelType = get_class($params['model']);
$notif->modelId = $params['model']->id;
$notif->type = $this->getNotifType();
$event->associationType = get_class($params['model']);
$event->associationId = $params['model']->id;
$event->type = $this->getEventType();
if($params['model']->hasAttribute('visibility'))
$event->visibility = $params['model']->visibility;
// $event->user = $this->parseOption('user',$params);
} else{
$text = $this->parseOption('text', $params);
$notif->type = 'custom';
$notif->text = $text;
$event->type = 'feed';
$event->subtype = $type;
$event->text = $text;
if($user == 'auto' && isset($params['model']) &&
$params['model']->hasAttribute('assignedTo') &&
!empty($params['model']->assignedTo)){
$event->user = $params['model']->assignedTo;
}elseif(!empty($user)){
$event->user = $user;
}else{
$event->user = 'admin';
}
}
if(!$this->parseOption('createNotif', $params)) {
if (!$notif->save()) {
return array(false, array_shift($notif->getErrors()));
}
}
if ($event->save()) {
return array (true, "");
} else {
return array(false, array_shift($event->getErrors()));
}
} | Class | 2 |
foreach ($days as $event) {
if (empty($event->eventdate->date) || ($viewrange == 'upcoming' && $event->eventdate->date < time()))
break;
if (empty($event->eventstart))
$event->eventstart = $event->eventdate->date;
$extitem[] = $event;
}
| Base | 1 |
function can_process($new) {
if (strlen($_POST['user_id']) < 4) {
display_error( _('The user login entered must be at least 4 characters long.'));
set_focus('user_id');
return false;
}
if (!$new && ($_POST['password'] != '')) {
if (strlen($_POST['password']) < 4) {
display_error( _('The password entered must be at least 4 characters long.'));
set_focus('password');
return false;
}
if (strstr($_POST['password'], $_POST['user_id']) != false) {
display_error( _('The password cannot contain the user login.'));
set_focus('password');
return false;
}
}
return true;
} | Base | 1 |
protected function _dimensions($path, $mime) {
if (strpos($mime, 'image') !== 0) return '';
$cache = $this->getDBdat($path);
if (isset($cache['width']) && isset($cache['height'])) {
return $cache['width'].'x'.$cache['height'];
}
$ret = '';
if ($work = $this->getWorkFile($path)) {
if ($size = @getimagesize($work)) {
$cache['width'] = $size[0];
$cache['height'] = $size[1];
$this->updateDBdat($path, $cache);
$ret = $size[0].'x'.$size[1];
}
}
is_file($work) && @unlink($work);
return $ret;
} | Base | 1 |
public function limit($value)
{
if ($value >= 0) {
$this->limit = $value;
}
return $this;
} | Base | 1 |
public function testTransactionSearch()
{
$transactionSearch = $this->gateway->transactionSearch(array(
'startDate' => '2015-01-01',
'endDate' => '2015-12-31'
));
$this->assertInstanceOf('\Omnipay\PayPal\Message\ExpressTransactionSearchRequest', $transactionSearch);
$this->assertInstanceOf('\DateTime', $transactionSearch->getStartDate());
$this->assertInstanceOf('\DateTime', $transactionSearch->getEndDate());
} | 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 |
$modelName = ucfirst ($module->name);
if (class_exists ($modelName)) {
// prefix widget class name with custom module model name and a delimiter
$cache[$widgetType][$modelName.'::TemplatesGridViewProfileWidget'] =
Yii::t(
'app', '{modelName} Summary', array ('{modelName}' => $modelName));
}
}
}
}
return $cache[$widgetType];
} | Base | 1 |
function searchCategory() {
return gt('Event');
}
| Base | 1 |
public static function backend($vars="") {
if(!empty($_GET['page'])) {
self::incBack($_GET['page']);
}else{
self::incBack('default');
}
}
| Base | 1 |
public static function getDueDate(Db $zdb, $member_id)
{
if (!$member_id) {
return '';
}
try {
$select = $zdb->select(self::TABLE, 'c');
$select->columns(
array(
'max_date' => new Expression('MAX(date_fin_cotis)')
)
)->join(
array('ct' => PREFIX_DB . ContributionsTypes::TABLE),
'c.' . ContributionsTypes::PK . '=ct.' . ContributionsTypes::PK,
array()
)->where(
Adherent::PK . ' = ' . $member_id
)->where(
array('cotis_extension' => new Expression('true'))
);
$results = $zdb->execute($select);
$result = $results->current();
$due_date = $result->max_date;
//avoid bad dates in postgres and bad mysql return from zenddb
if ($due_date == '0001-01-01 BC' || $due_date == '1901-01-01') {
$due_date = '';
}
return $due_date;
} catch (Throwable $e) {
Analog::log(
'An error occurred trying to retrieve member\'s due date',
Analog::ERROR
);
throw $e;
}
} | Base | 1 |
public function uninstall($templatename)
{
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
if (!Template::hasInheritance($templatename)) {
TemplateConfiguration::uninstall($templatename);
} else {
Yii::app()->setFlashMessage(sprintf(gT("You can't uninstall template '%s' because some templates inherit from it."), $templatename), 'error');
}
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
}
$this->getController()->redirect(array("admin/themeoptions"));
} | Compound | 4 |
foreach ($allusers as $uid) {
$u = user::getUserById($uid);
expPermissions::grant($u, 'manage', $sloc);
}
| Base | 1 |
function searchName() {
return gt("Calendar Event");
}
| Base | 1 |
public function confirm()
{
$project = $this->getProject();
$swimlane = $this->getSwimlane();
$this->response->html($this->helper->layout->project('swimlane/remove', array(
'project' => $project,
'swimlane' => $swimlane,
)));
} | Base | 1 |
function update_optiongroup_master() {
global $db;
$id = empty($this->params['id']) ? null : $this->params['id'];
$og = new optiongroup_master($id);
$oldtitle = $og->title;
$og->update($this->params);
// if the title of the master changed we should update the option groups that are already using it.
if ($oldtitle != $og->title) {
$db->sql('UPDATE '.$db->prefix.'optiongroup SET title="'.$og->title.'" WHERE title="'.$oldtitle.'"');
}
expHistory::back();
} | 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
));
} | Base | 1 |
public function renameUser($new_name)
{
// Rename only if a new name is really new
if ($this->userName != $new_name) {
// Save old name
$old_name = $this->userName;
// Rename user
$this->userName = $new_name;
$this->save();
// Send message about renaming
$message = getlocal(
"The visitor changed their name <strong>{0}</strong> to <strong>{1}</strong>",
array($old_name, $new_name),
$this->locale,
true
);
$this->postMessage(self::KIND_EVENTS, $message);
}
} | Base | 1 |
public function uploadImage()
{
$filesCheck = array_filter($_FILES);
if (!empty($filesCheck) && $this->approvedFileExtension($_FILES['file']['name'], 'image') && strpos($_FILES['file']['type'], 'image/') !== false) {
ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = $this->root . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'userTabs' . DIRECTORY_SEPARATOR;
$this->makeDir($targetPath);
$targetFile = $targetPath . $_FILES['file']['name'];
$this->setAPIResponse(null, pathinfo($_FILES['file']['name'], PATHINFO_BASENAME) . ' has been uploaded', null);
return move_uploaded_file($tempFile, $targetFile);
}
} | Base | 1 |
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$item = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_URL_getCommon()
. '&hideNavItem=true'
. '&itemType=' . urldecode($this->getItemType())
. '&itemName=' . urldecode($item)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('lightbulb_off.png', __('Hide'))
. '</a></span>';
}
return $ret;
} | Base | 1 |
public function autocomplete() {
return;
global $db;
$model = $this->params['model'];
$mod = new $model();
$srchcol = explode(",",$this->params['searchoncol']);
/*for ($i=0; $i<count($srchcol); $i++) {
if ($i>=1) $sql .= " OR ";
$sql .= $srchcol[$i].' LIKE \'%'.$this->params['query'].'%\'';
}*/
// $sql .= ' AND parent_id=0';
//eDebug($sql);
//$res = $mod->find('all',$sql,'id',25);
$sql = "select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from ".$db->prefix."product as p INNER JOIN ".$db->prefix."content_expfiles as cef ON p.id=cef.content_id INNER JOIN ".$db->prefix."expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') desc LIMIT 25";
//$res = $db->selectObjectsBySql($sql);
//$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`');
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Base | 1 |
private static function sign($input, $key, $algo = 'HS256')
{
switch ($algo) {
case 'HS256':
return hash_hmac('sha256', $input, $key, true);
case 'HS384':
return hash_hmac('sha384', $input, $key, true);
case 'HS512':
return hash_hmac('sha512', $input, $key, true);
case 'RS256':
return JWT::generateRSASignature($input, $key, OPENSSL_ALGO_SHA256);
case 'RS384':
return JWT::generateRSASignature($input, $key, OPENSSL_ALGO_SHA384);
case 'RS512':
return JWT::generateRSASignature($input, $key, OPENSSL_ALGO_SHA512);
default:
throw new Exception("Unsupported or invalid signing algorithm.");
}
} | Class | 2 |
public static function dplReplaceParserFunction( &$parser, $text, $pat = '', $repl = '' ) {
$parser->addTrackingCategory( 'dplreplace-parserfunc-tracking-category' );
if ( $text == '' || $pat == '' ) {
return '';
}
# convert \n to a real newline character
$repl = str_replace( '\n', "\n", $repl );
# replace
if ( !self::isRegexp( $pat ) ) {
$pat = '`' . str_replace( '`', '\`', $pat ) . '`';
}
return @preg_replace( $pat, $repl, $text );
} | Class | 2 |
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 |
. PMA_Util::getIcon('b_favorite.png')
. '</a>';
$html .= '<a href="sql.php?server=' . $GLOBALS['server']
. '&db=' . $table['db']
. '&table=' . $table['table']
. '&token=' . $_SESSION[' PMA_token ']
. '">`' . $table['db'] . '`.`' . $table['table'] . '`</a>';
$html .= '</li>';
}
}
} else {
$html .= '<li class="warp_link">'
. ($this->_tableType == 'recent'
?__('There are no recent tables.')
:__('There are no favorite tables.'))
. '</li>';
} | Base | 1 |
$tokens = preg_split( '/ - */', $title );
$newKey = '';
foreach ( $tokens as $token ) {
$initial = substr( $token, 0, 1 );
if ( $initial >= '1' && $initial <= '7' ) {
$newKey .= $initial;
$suit = substr( $token, 1 );
if ( $suit == '♣' ) {
$newKey .= '1';
} elseif ( $suit == '♦' ) {
$newKey .= '2';
} elseif ( $suit == '♥' ) {
$newKey .= '3';
} elseif ( $suit == '♠' ) {
$newKey .= '4';
} elseif ( strtolower( $suit ) == 'sa' || strtolower( $suit ) == 'nt' ) {
$newKey .= '5 ';
} else {
$newKey .= $suit;
}
} elseif ( strtolower( $initial ) == 'p' ) {
$newKey .= '0 ';
} elseif ( strtolower( $initial ) == 'x' ) {
$newKey .= '8 ';
} else {
$newKey .= $token;
}
}
$sortKeys[$key] = $newKey;
}
asort( $sortKeys );
foreach ( $sortKeys as $oldKey => $newKey ) {
$sortedArticles[] = $articles[$oldKey];
}
return $sortedArticles;
} | Class | 2 |
public function testReturnsAsIsWhenNoChanges()
{
$request = new Psr7\Request('GET', 'http://foo.com');
$this->assertSame($request, Psr7\modify_request($request, []));
} | Base | 1 |
public function approve() {
expHistory::set('editable', $this->params);
/* The global constants can be overriden by passing appropriate params */
//sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
$require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login'];
$require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval'];
$require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification'];
$notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email'];
if (empty($this->params['id'])) {
flash('error', gt('No ID supplied for note to approve'));
$lastUrl = expHistory::getLast('editable');
}
$simplenote = new expSimpleNote($this->params['id']);
assign_to_template(array(
'simplenote'=>$simplenote,
'require_login'=>$require_login,
'require_approval'=>$require_approval,
'require_notification'=>$require_notification,
'notification_email'=>$notification_email,
'tab'=>$this->params['tab']
));
} | Base | 1 |
function check_file_dir_name($label) {
if (empty($label) || preg_match('/[^A-Za-z0-9_.-]/', $label))
die(xlt("ERROR: The following variable contains invalid characters").": ". attr($label));
} | Class | 2 |
public function validate() {
global $db;
// check for an sef url field. If it exists make sure it's valid and not a duplicate
//this needs to check for SEF URLS being turned on also: TODO
if (property_exists($this, 'sef_url') && !(in_array('sef_url', $this->do_not_validate))) {
if (empty($this->sef_url)) $this->makeSefUrl();
if (!isset($this->validates['is_valid_sef_name']['sef_url'])) $this->validates['is_valid_sef_name']['sef_url'] = array();
if (!isset($this->validates['uniqueness_of']['sef_url'])) $this->validates['uniqueness_of']['sef_url'] = array();
}
// safeguard again loc data not being pass via forms...sometimes this happens when you're in a router
// mapped view and src hasn't been passed in via link to the form
if (isset($this->id) && empty($this->location_data)) {
$loc = $db->selectValue($this->tablename, 'location_data', 'id=' . $this->id);
if (!empty($loc)) $this->location_data = $loc;
}
// run the validation as defined in the models
if (!isset($this->validates)) return true;
$messages = array();
$post = empty($_POST) ? array() : expString::sanitize($_POST);
foreach ($this->validates as $validation=> $field) {
foreach ($field as $key=> $value) {
$fieldname = is_numeric($key) ? $value : $key;
$opts = is_numeric($key) ? array() : $value;
$ret = expValidator::$validation($fieldname, $this, $opts);
if (!is_bool($ret)) {
$messages[] = $ret;
expValidator::setErrorField($fieldname);
unset($post[$fieldname]);
}
}
}
if (count($messages) >= 1) expValidator::failAndReturnToForm($messages, $post);
} | Base | 1 |
function get_language_attributes( $doctype = 'html' ) {
$attributes = array();
if ( function_exists( 'is_rtl' ) && is_rtl() )
$attributes[] = 'dir="rtl"';
if ( $lang = get_bloginfo('language') ) {
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
$attributes[] = "lang=\"$lang\"";
if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
$attributes[] = "xml:lang=\"$lang\"";
}
$output = implode(' ', $attributes);
/**
* Filters the language attributes for display in the html tag.
*
* @since 2.5.0
* @since 4.3.0 Added the `$doctype` parameter.
*
* @param string $output A space-separated list of language attributes.
* @param string $doctype The type of html document (xhtml|html).
*/
return apply_filters( 'language_attributes', $output, $doctype );
} | Base | 1 |
public static function isActive () {
switch (SMART_URL) {
case true:
if (Options::v('multilang_enable') === 'on') {
$langs = Session::val('lang');
if($langs != '') {
$lang = Session::val('lang');
}else{
$lang = '';
}
}else{
$lang = '';
}
break;
default:
if (Options::v('multilang_enable') === 'on') {
$langs = Session::val('lang');
if($langs != '') {
$lang = Session::val('lang');
}else{
$lang = isset($_GET['lang'])? $_GET['lang']: '' ;
}
}else{
$lang = '';
}
break;
}
return $lang;
}
| Base | 1 |
private function _addfirstcategorydate( $option ) {
//@TODO: This should be programmatically determining which categorylink table to use instead of assuming the first one.
$this->addSelect(
[
'cl_timestamp' => "DATE_FORMAT(cl1.cl_timestamp, '%Y%m%d%H%i%s')"
]
);
} | Class | 2 |
$section = new section(intval($page));
if ($section) {
// self::deleteLevel($section->id);
$section->delete();
}
}
}
| Base | 1 |
foreach ($indexesOld as $index) {
if (\in_array('name', $index->getColumns()) || \in_array('mail', $index->getColumns())) {
$this->indexesOld[] = $index;
$this->addSql('DROP INDEX ' . $index->getName() . ' ON ' . $users);
}
} | Compound | 4 |
public function setModel(Model $model)
{
$this->model = $model;
$this->extensions = $this->model->getAllowedExtensions();
$this->from($this->model->getObjectTypeDirName());
return $this;
} | Base | 1 |
public static function login() {
user::login(expString::sanitize($_POST['username']),expString::sanitize($_POST['password']));
if (!isset($_SESSION[SYS_SESSION_KEY]['user'])) { // didn't successfully log in
flash('error', gt('Invalid Username / Password'));
if (expSession::is_set('redirecturl_error')) {
$url = expSession::get('redirecturl_error');
expSession::un_set('redirecturl_error');
header("Location: ".$url);
} else {
expHistory::back();
}
} else { // we're logged in
global $user;
if (expSession::get('customer-login')) expSession::un_set('customer-login');
if (!empty($_POST['username'])) flash('message', gt('Welcome back').' '.expString::sanitize($_POST['username']));
if ($user->isAdmin()) {
expHistory::back();
} else {
foreach ($user->groups as $g) {
if (!empty($g->redirect)) {
$url = URL_FULL.$g->redirect;
break;
}
}
if (isset($url)) {
header("Location: ".$url);
} else {
expHistory::back();
}
}
}
} | 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 |
function unlockTables() {
$sql = "UNLOCK TABLES";
$res = mysqli_query($this->connection, $sql);
return $res;
} | Base | 1 |
function updateObject($object, $table, $where=null, $identifier='id', $is_revisioned=false) {
if ($is_revisioned) {
$object->revision_id++;
//if ($table=="text") eDebug($object);
$res = $this->insertObject($object, $table);
//if ($table=="text") eDebug($object,true);
$this->trim_revisions($table, $object->$identifier, WORKFLOW_REVISION_LIMIT);
return $res;
}
$sql = "UPDATE " . $this->prefix . "$table SET ";
foreach (get_object_vars($object) as $var => $val) {
//We do not want to save any fields that start with an '_'
//if($is_revisioned && $var=='revision_id') $val++;
if ($var{0} != '_') {
if (is_array($val) || is_object($val)) {
$val = serialize($val);
$sql .= "`$var`='".$val."',";
} else {
$sql .= "`$var`='" . $this->escapeString($val) . "',";
}
}
}
$sql = substr($sql, 0, -1) . " WHERE ";
if ($where != null)
$sql .= $this->injectProof($where);
else
$sql .= "`" . $identifier . "`=" . $object->$identifier;
//if ($table == 'text') eDebug($sql,true);
$res = (@mysqli_query($this->connection, $sql) != false);
return $res;
} | Base | 1 |
public function testNewInstanceWhenAddingHeader()
{
$r = new Response(200, ['Foo' => 'Bar']);
$r2 = $r->withAddedHeader('Foo', 'Baz');
$this->assertNotSame($r, $r2);
$this->assertEquals('Bar, Baz', $r2->getHeaderLine('foo'));
} | Base | 1 |
$contents[] = ['class' => 'text-center', 'text' => tep_draw_bootstrap_button(IMAGE_SAVE, 'fas fa-save', null, 'primary', null, 'btn-success xxx text-white mr-2') . tep_draw_bootstrap_button(IMAGE_CANCEL, 'fas fa-times', tep_href_link('orders_status.php', 'page=' . $_GET['page']), null, null, 'btn-light')]; | 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 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();
}
}
| 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(),
));
}
| Base | 1 |
public function store(CurrencyFormRequest $request)
{
/** @var User $user */
$user = auth()->user();
$data = $request->getCurrencyData();
if (!$this->userRepository->hasRole($user, 'owner')) {
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);
return redirect($this->getPreviousUri('currencies.create.uri'));
}
$data['enabled'] = true;
try {
$currency = $this->repository->store($data);
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);
$request->session()->flash('error', (string) trans('firefly.could_not_store_currency'));
$currency = null;
}
$redirect = redirect($this->getPreviousUri('currencies.create.uri'));
if (null !== $currency) {
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
Log::channel('audit')->info('Created (POST) currency.', $data);
if (1 === (int) $request->get('create_another')) {
$request->session()->put('currencies.create.fromStore', true);
$redirect = redirect(route('currencies.create'))->withInput();
}
}
return $redirect;
} | Compound | 4 |
function mso_segment_array()
{
$CI = &get_instance();
if (isset($_SERVER['REQUEST_URI']) and $_SERVER['REQUEST_URI']) {
// http://localhost/page/privet?get=hello
$url = getinfo('site_protocol');
$url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url = str_replace($CI->config->config['base_url'], '', $url); // page/privet?get=hello
if (strpos($url, '?') !== FALSE) {
// есть «?»
$url = explode('?', $url); // разделим в массив
$url = $url[0]; // сегменты - это только первая часть
$url = explode('/', $url); // разделим в массив по /
// нужно изменить нумерацию - начало с 1
$out = [];
$i = 1;
foreach ($url as $val) {
if ($val) {
$out[$i] = $val;
$i++;
}
}
return $out;
} else {
return $CI->uri->segment_array();
}
} else {
return $CI->uri->segment_array();
}
}
| 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'])));
} | Base | 1 |
public function test_empty_content_multiple_spaces() {
$result = $this->myxmlrpcserver->wp_newComment(
array(
1,
'administrator',
'administrator',
self::$post->ID,
array(
'content' => ' ',
),
)
);
$this->assertIXRError( $result );
$this->assertSame( 403, $result->code );
} | Class | 2 |
public static function dplChapterParserFunction( &$parser, $text = '', $heading = ' ', $maxLength = -1, $page = '?page?', $link = 'default', $trim = false ) {
$parser->addTrackingCategory( 'dplchapter-parserfunc-tracking-category' );
$output = \DPL\LST::extractHeadingFromText( $parser, $page, '?title?', $text, $heading, '', $sectionHeading, true, $maxLength, $link, $trim );
return $output[0];
} | Class | 2 |
public function query($sql, $fetch_mode='object')
{
$this->lastError = '';
$this->lastResult = '';
switch($fetch_mode)
{
case 'array':
$fetch = PDO::FETCH_ASSOC;
break;
case 'object':
default:
$fetch = PDO::FETCH_OBJ;
break;
}
try
{
$statement = $this->db->query($sql);
$this->queries_count++;
// avoid firing a fatal error exception when the result is NULL
// and the query is not malformed
if(!$statement)
return false;
$statement->setFetchMode($fetch);
$this->lastResult = $statement->fetchAll();
$statement->closeCursor();
unset($statement);
}
catch(PDOException $e)
{
$this->lastError = $e->getMessage();
}
catch(Exception $e)
{
return false;
}
return empty($this->lastError);
}
| Base | 1 |
public function getQueryGroupby()
{
// SubmittedOn is stored in the artifact
return 'a.submitted_on';
} | Base | 1 |
function __construct() {
$this->mDb = GlobalNewFilesHooks::getGlobalDB( DB_REPLICA, 'gnf_files' );
if ( $this->getRequest()->getText( 'sort', 'files_date' ) == 'files_date' ) {
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
} else {
$this->mDefaultDirection = IndexPager::DIR_ASCENDING;
}
parent::__construct( $this->getContext() );
} | Class | 2 |
function escape_command($command) {
return preg_replace("/(\\\$|`)/", "", $command);
} | Base | 1 |
public static function unpublish($id) {
$id = Typo::int($id);
$ins = array(
'table' => 'posts',
'id' => $id,
'key' => array(
'status' => '0'
)
);
$post = Db::update($ins);
return $post;
}
| Base | 1 |
public function __construct () {
if (self::existConf()) {
# code...
self::config('config');
self::lang(GX_LANG);
}else{
GxMain::install();
}
} | Base | 1 |
$path = Helpers::isAbsolute($item) ? $item : ($this->getRepositoryPath() . DIRECTORY_SEPARATOR . $item);
if (!file_exists($path)) {
throw new GitException("The path at '$item' does not represent a valid file.");
}
$this->run('add', $item);
} | Class | 2 |
public static function run() {
//print_r(self::$hooks[$var]);
$hooks = self::$hooks;
$num_args = func_num_args();
$args = func_get_args();
// print_r($args);
// if($num_args < 2)
// trigger_error("Insufficient arguments", E_USER_ERROR);
// Hook name should always be first argument
$hook_name = array_shift($args);
if(!isset($hooks[$hook_name]))
return; // No plugins have registered this hook
// print_r($args[0]);
// $args = (is_array($args))?$args[0]: $args;
if (is_array($hooks[$hook_name])) {
$val = '';
foreach($hooks[$hook_name] as $func){
if ($func != '') {
// $args = call_user_func_array($func, $args); //
$val .= $func((array)$args);
}else{
$val .= $args;
}
}
return $val;
}
}
| Base | 1 |
public function getAdminViewItemLink($icmsObj, $onlyUrl=false, $withimage=false) {
$ret = $this->handler->_moduleUrl . "admin/"
. $this->handler->_page . "?op=view&"
. $this->handler->keyName . "="
. $icmsObj->getVar($this->handler->keyName);
if ($onlyUrl) {
return $ret;
} elseif ($withimage) {
return "<a href='" . $ret . "'>
<img src='" . ICMS_IMAGES_SET_URL
. "/actions/viewmag.png' style='vertical-align: middle;' alt='"
. _CO_ICMS_ADMIN_VIEW . "' title='"
. _CO_ICMS_ADMIN_VIEW . "'/></a>";
}
return "<a href='" . $ret . "'>" . $icmsObj->getVar($this->handler->identifierName) . "</a>";
}
| Base | 1 |
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;
}
| Base | 1 |
public function uploadCompanyLogo(Request $request)
{
$company = Company::find($request->header('company'));
$this->authorize('manage company', $company);
$data = json_decode($request->company_logo);
if ($data) {
$company = Company::find($request->header('company'));
if ($company) {
$company->clearMediaCollection('logo');
$company->addMediaFromBase64($data->data)
->usingFileName($data->name)
->toMediaCollection('logo');
}
}
return response()->json([
'success' => true,
]);
} | Base | 1 |
public function __construct(?string $message = null)
{
if ($message === null) {
$message = _('Invalid email/password combination.');
}
parent::__construct($message, 0);
} | Base | 1 |
public function getTopRated(){
$url = "http://api.themoviedb.org/3/movie/top_rated?api_key=".$this->apikey;
$top_rated = $this->curl($url);
return $top_rated;
}
| 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();
} | Base | 1 |
public function setFrameAncestors(Response $response)
{
$iframeHosts = $this->getAllowedIframeHosts();
array_unshift($iframeHosts, "'self'");
$cspValue = 'frame-ancestors ' . implode(' ', $iframeHosts);
$response->headers->set('Content-Security-Policy', $cspValue, false);
} | Base | 1 |
public function actionDeleteDropdown() {
$dropdowns = Dropdowns::model()->findAll();
if (isset($_POST['dropdown'])) {
if ($_POST['dropdown'] != Actions::COLORS_DROPDOWN_ID) {
$model = Dropdowns::model()->findByPk($_POST['dropdown']);
$model->delete();
$this->redirect('manageDropDowns');
}
}
$this->render('deleteDropdowns', array(
'dropdowns' => $dropdowns,
));
} | Class | 2 |
$controller = new $ctlname();
if (method_exists($controller,'isSearchable') && $controller->isSearchable()) {
// $mods[$controller->name()] = $controller->addContentToSearch();
$mods[$controller->searchName()] = $controller->addContentToSearch();
}
}
uksort($mods,'strnatcasecmp');
assign_to_template(array(
'mods'=>$mods
));
} | Base | 1 |
function ngettext($single, $plural, $number) {
if ($this->short_circuit) {
if ($number != 1)
return $plural;
else
return $single;
}
// find out the appropriate form
$select = $this->select_string($number);
// this should contains all strings separated by NULLs
$key = $single . chr(0) . $plural;
if ($this->enable_cache) {
if (! array_key_exists($key, $this->cache_translations)) {
return ($number != 1) ? $plural : $single;
} else {
$result = $this->cache_translations[$key];
$list = explode(chr(0), $result);
return $list[$select];
}
} else {
$num = $this->find_string($key);
if ($num == -1) {
return ($number != 1) ? $plural : $single;
} else {
$result = $this->get_translation_string($num);
$list = explode(chr(0), $result);
return $list[$select];
}
}
} | Base | 1 |
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
} | Compound | 4 |
public function validate() {
global $db;
// check for an sef url field. If it exists make sure it's valid and not a duplicate
//this needs to check for SEF URLS being turned on also: TODO
if (property_exists($this, 'sef_url') && !(in_array('sef_url', $this->do_not_validate))) {
if (empty($this->sef_url)) $this->makeSefUrl();
if (!isset($this->validates['is_valid_sef_name']['sef_url'])) $this->validates['is_valid_sef_name']['sef_url'] = array();
if (!isset($this->validates['uniqueness_of']['sef_url'])) $this->validates['uniqueness_of']['sef_url'] = array();
}
// safeguard again loc data not being pass via forms...sometimes this happens when you're in a router
// mapped view and src hasn't been passed in via link to the form
if (isset($this->id) && empty($this->location_data)) {
$loc = $db->selectValue($this->tablename, 'location_data', 'id=' . $this->id);
if (!empty($loc)) $this->location_data = $loc;
}
// run the validation as defined in the models
if (!isset($this->validates)) return true;
$messages = array();
$post = empty($_POST) ? array() : expString::sanitize($_POST);
foreach ($this->validates as $validation=> $field) {
foreach ($field as $key=> $value) {
$fieldname = is_numeric($key) ? $value : $key;
$opts = is_numeric($key) ? array() : $value;
$ret = expValidator::$validation($fieldname, $this, $opts);
if (!is_bool($ret)) {
$messages[] = $ret;
expValidator::setErrorField($fieldname);
unset($post[$fieldname]);
}
}
}
if (count($messages) >= 1) expValidator::failAndReturnToForm($messages, $post);
} | 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,
));
} | Class | 2 |
public function getQuerySelect()
{
} | Base | 1 |
function invalidTestController($port) {
$host = php_uname('n');
$filename = __DIR__.'/request-doesnotexist.dat';
$file = fopen($filename, 'rb');
$req_dat = fread($file, filesize($filename));
fclose($file);
// Repeat the data three times, to make it invalid. This particular bytestream
// (and ones like it -- repeat 3 times!) in particular used to tickle a
// use-after-free in the FastCGI support.
$req_dat = $req_dat . $req_dat . $req_dat;
$sock = fsockopen($host, $port);
fwrite($sock, $req_dat);
fclose($sock);
// Should still be able to recover and respond to a request over the port on a
// new TCP connection.
echo request($host, $port, 'hello.php');
echo "\n";
} | Class | 2 |
protected function LoadSize($blob)
{
if (!$blob)
return;
$args = array();
$args[] = '-s';
$args[] = $blob->GetHash();
return $this->exe->Execute($blob->GetProject()->GetPath(), GIT_CAT_FILE, $args);
} | Base | 1 |
function delete() {
global $db;
if (empty($this->params['id'])) return false;
$product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);
$product = new $product_type($this->params['id'], true, false);
//eDebug($product_type);
//eDebug($product, true);
//if (!empty($product->product_type_id)) {
//$db->delete($product_type, 'id='.$product->product_id);
//}
$db->delete('option', 'product_id=' . $product->id . " AND optiongroup_id IN (SELECT id from " . $db->prefix . "optiongroup WHERE product_id=" . $product->id . ")");
$db->delete('optiongroup', 'product_id=' . $product->id);
//die();
$db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type="' . $product_type . '"');
if ($product->product_type == "product") {
if ($product->hasChildren()) {
$this->deleteChildren();
}
}
$product->delete();
flash('message', gt('Product deleted successfully.'));
expHistory::back();
} | Base | 1 |
$this->subtaskTimeTrackingModel->logEndTime($subtaskId, $this->userSession->getId());
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($task['id']);
} | Base | 1 |
public function start()
{
if ($this->started) {
return true;
}
$this->loadSession();
if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) {
// This condition matches only PHP 5.3 + internal save handlers
$this->saveHandler->setActive(true);
}
return true;
} | Base | 1 |
protected function Start()
{
$sCurrentStepClass = $this->sInitialStepClass;
$oStep = new $sCurrentStepClass($this, $this->sInitialState);
$this->DisplayStep($oStep);
} | Base | 1 |
unlink($file);
}
foreach (self::$tempImages as $versions) {
foreach ($versions as $file) {
if ($file === self::$broken_image) {
continue;
}
if ($debugPng) {
print "[unlink temp image $file]";
}
if (file_exists($file)) {
unlink($file);
}
}
}
self::$_cache = [];
self::$tempImages = [];
} | Base | 1 |
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
if ($input->getOption('semver')) {
$io->writeln(Constants::VERSION . '-' . Constants::STATUS);
return 0;
}
if ($input->getOption('short')) {
$io->writeln(Constants::VERSION);
return 0;
}
if ($input->getOption('name')) {
$io->writeln(Constants::NAME);
return 0;
}
if ($input->getOption('candidate')) {
$io->writeln(Constants::STATUS);
return 0;
}
$io->writeln(Constants::SOFTWARE . ' - ' . Constants::VERSION . ' ' . Constants::STATUS . ' (' . Constants::NAME . ') by Kevin Papst and contributors.');
return 0;
} | Base | 1 |
$contents = ['form' => tep_draw_form('currencies', 'currencies.php', 'page=' . $_GET['page'] . (isset($cInfo) ? '&cID=' . $cInfo->currencies_id : '') . '&action=insert')]; | 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.