code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
public function session() { // Test if logged in, log in if not, log in. try { $this->assertElementPresent('css=ul#user-menu'); } catch (PHPUnit_Framework_AssertionFailedError $e) { /* If this isn't the first time we've logged in, we have a problem; * the user should have been logged in throughout the life of the * test case class. Append t */ if (!$this->firstLogin) array_push($this->verificationErrors, $e->toString()); $this->firstLogin = false; $this->login(); return 0; } try { $this->assertCorrectUser(); } catch (PHPUnit_Framework_AssertionFailedError $e) { /** * The browser is logged in but not as the correct user. */ $this->logout(); $this->login(); $this->firstLogin = false; return 0; } // Indicator of whether the session was already initialized properly return 1; }
Class
2
public function rules() { return [ 'upload_receipt' => [ 'nullable', new Base64Mime(['gif', 'jpg', 'png']) ] ]; }
Base
1
function reset_stats() { // global $db; // reset the counters // $db->sql ('UPDATE '.$db->prefix.'banner SET impressions=0 WHERE 1'); banner::resetImpressions(); // $db->sql ('UPDATE '.$db->prefix.'banner SET clicks=0 WHERE 1'); banner::resetClicks(); // let the user know we did stuff. flash('message', gt("Banner statistics reset.")); expHistory::back(); }
Base
1
public static function remove_old_unconfirmed_accounts() { global $DB; global $website; $ok = false; $DB->query(' SELECT ex.id FROM ( SELECT id, activation_key, SUBSTRING_INDEX(activation_key, "-", -1) AS expiration_time FROM nv_webusers WHERE website = ' . protect($website->id) . ' AND access = 1 AND activation_key != "" ) ex WHERE ex.activation_key <> ex.expiration_time AND '.time().' > ex.expiration_time '); $rs = $DB->result('id'); if(!empty($rs)) { $ok = $DB->execute(' DELETE FROM nv_webusers wu WHERE wu.id IN ('.implode(",", $rs).') '); } if($ok) return count($rs); else return 0; }
Base
1
public function assignDefaultRoles() { global $gMessage, $gL10n; $this->db->startTransaction(); // every user will get the default roles for registration, if the current user has the right to assign roles // than the roles assignment dialog will be shown $sql = 'SELECT rol_id FROM '.TBL_ROLES.' INNER JOIN '.TBL_CATEGORIES.' ON cat_id = rol_cat_id WHERE rol_default_registration = 1 AND cat_org_id = ? -- $this->organizationId'; $defaultRolesStatement = $this->db->queryPrepared($sql, array($this->organizationId)); if ($defaultRolesStatement->rowCount() === 0) { $gMessage->show($gL10n->get('PRO_NO_DEFAULT_ROLE')); // => EXIT } while ($rolId = $defaultRolesStatement->fetchColumn()) { // starts a membership for role from now $this->setRoleMembership($rolId); } $this->db->endTransaction(); }
Base
1
public function pending() { // global $db; // make sure we have what we need. if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('Your subscriber ID was not supplied.')); // find the subscriber and their pending subscriptions $ealerts = expeAlerts::getPendingBySubscriber($this->params['id']); $subscriber = new subscribers($this->params['id']); // render the template assign_to_template(array( 'subscriber'=>$subscriber, 'ealerts'=>$ealerts )); }
Base
1
public function testCreateRelationshipMeta() { // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta(null, null, null, array(), null); self::assertCount(1, $GLOBALS['log']->calls['fatal']); // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta(null, null, null, array(), 'Contacts'); self::assertCount(1, $GLOBALS['log']->calls['fatal']); // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta(null, null, null, array(), 'Contacts', true); self::assertCount(1, $GLOBALS['log']->calls['fatal']); // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta('User', null, null, array(), 'Contacts'); self::assertCount(6, $GLOBALS['log']->calls['fatal']); // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta('User', $this->db, null, array(), 'Contacts'); self::assertNotTrue(isset($GLOBALS['log']->calls['fatal'])); // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta('Nonexists1', $this->db, null, array(), 'Nonexists2'); self::assertCount(1, $GLOBALS['log']->calls['debug']); // test $GLOBALS['log']->reset(); SugarBean::createRelationshipMeta('User', null, null, array(), 'Contacts'); self::assertCount(6, $GLOBALS['log']->calls['fatal']); }
Base
1
private function runCallback() { foreach ($this->records as &$record) { if (isset($record->ref_type)) { $refType = $record->ref_type; if (class_exists($record->ref_type)) { $type = new $refType(); $classinfo = new ReflectionClass($type); if ($classinfo->hasMethod('paginationCallback')) { $item = new $type($record->original_id); $item->paginationCallback($record); } } } } }
Class
2
$this->assertEquals(array($flashes[$key]), $val); ++$i; }
Base
1
public function search(){ // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria; $username = Yii::app()->user->name; $criteria->addCondition("uploadedBy='$username' OR private=0 OR private=null"); $criteria->addCondition("associationType != 'theme'"); return $this->searchBase($criteria); }
Class
2
public function update() { $project = $this->getProject(); $tag_id = $this->request->getIntegerParam('tag_id'); $tag = $this->tagModel->getById($tag_id); $values = $this->request->getValues(); list($valid, $errors) = $this->tagValidator->validateModification($values); if ($tag['project_id'] != $project['id']) { throw new AccessForbiddenException(); } if ($valid) { if ($this->tagModel->update($values['id'], $values['name'])) { $this->flash->success(t('Tag updated successfully.')); } else { $this->flash->failure(t('Unable to update this tag.')); } $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); } else { $this->edit($values, $errors); } }
Base
1
public function setActive($flag) { if (PHP_VERSION_ID >= 50400) { throw new \LogicException('This method is disabled in PHP 5.4.0+'); } $this->active = (bool) $flag; }
Base
1
function selectBillingOptions() { }
Base
1
$stat = $this->stat($p); if (!$stat) { // invalid links continue; } if (!empty($stat['hidden']) || !$this->mimeAccepted($stat['mime'], $mimes)) { continue; } $name = $stat['name']; if ((!$mimes || $stat['mime'] !== 'directory') && $this->stripos($name, $q) !== false) { $stat['path'] = $this->path($stat['hash']); if ($this->URL && !isset($stat['url'])) { $path = str_replace($this->separator, '/', substr($p, strlen($this->root) + 1)); if ($this->encoding) { $path = str_replace('%2F', '/', rawurlencode($this->convEncIn($path, true))); } $stat['url'] = $this->URL . $path; } $result[] = $stat; } if ($stat['mime'] == 'directory' && $stat['read'] && !isset($stat['alias'])) { $result = array_merge($result, $this->doSearch($p, $q, $mimes)); } } return $result; }
Base
1
$method = $this->request->get('_method', $this->query->get('_method', 'POST')); if (\is_string($method)) { $this->method = strtoupper($method); } } } }
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('"',"&quot;",$str); $str = str_replace("'","&#39;",$str); $str = str_replace("’","&rsquo;",$str); $str = str_replace("‘","&lsquo;",$str); $str = str_replace("®","&#174;",$str); $str = str_replace("–","-", $str); $str = str_replace("—","&#151;", $str); $str = str_replace("”","&rdquo;", $str); $str = str_replace("“","&ldquo;", $str); $str = str_replace("¼","&#188;",$str); $str = str_replace("½","&#189;",$str); $str = str_replace("¾","&#190;",$str); $str = str_replace("™","&trade;", $str); $str = trim($str); if ($unescape) { $str = stripcslashes($str); } else { $str = addslashes($str); } return $str; }
Base
1
public function setBanner($banner) { $return = $this->setOneToOne($banner, Banner::class, 'banner', 'container'); $this->setType('ctBanner'); return $return; }
Base
1
public function remove() { $id = (int)$this->id; if ($this->isSystemType()) { throw new \RuntimeException(_T("You cannot delete system payment types!")); } try { $delete = $this->zdb->delete(self::TABLE); $delete->where( self::PK . ' = ' . $id ); $this->zdb->execute($delete); $this->deleteTranslation($this->name); Analog::log( 'Payment type #' . $id . ' (' . $this->name . ') deleted successfully.', Analog::INFO ); return true; } catch (Throwable $e) { Analog::log( 'Unable to delete payment type ' . $id . ' | ' . $e->getMessage(), Analog::ERROR ); throw $e; } }
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 testPathMustBeValid() { (new Uri(''))->withPath([]); }
Base
1
public function handleRequest() { /* Load error handling class */ $this->loadErrorHandler(); $this->modx->invokeEvent('OnHandleRequest'); /* save page to manager object. allow custom actionVar choice for extending classes. */ $this->action = isset($_REQUEST[$this->actionVar]) ? $_REQUEST[$this->actionVar] : $this->defaultAction; /* invoke OnManagerPageInit event */ $this->modx->invokeEvent('OnManagerPageInit',array('action' => $this->action)); $this->prepareResponse(); }
Base
1
protected function configure() { $this ->setName('kimai:version') ->setDescription('Receive version information') ->setHelp('This command allows you to fetch various version information about Kimai.') ->addOption('name', null, InputOption::VALUE_NONE, 'Display the major release name') ->addOption('candidate', null, InputOption::VALUE_NONE, 'Display the current version candidate (e.g. "stable" or "dev")') ->addOption('short', null, InputOption::VALUE_NONE, 'Display the version only') ->addOption('semver', null, InputOption::VALUE_NONE, 'Semantical versioning (SEMVER) compatible version string') ; }
Base
1
public static function regdate($id){ $usr = Db::result( sprintf("SELECT * FROM `user` WHERE `id` = '%d' OR `userid` = '%s' LIMIT 1", Typo::int($id), Typo::cleanX($id) ) ); return $usr[0]->join_date; }
Base
1
static function lookup($var) { if (is_array($var)) return parent::lookup($var); elseif (is_numeric($var)) return parent::lookup(array('staff_id'=>$var)); elseif (Validator::is_email($var)) return parent::lookup(array('email'=>$var)); elseif (is_string($var)) return parent::lookup(array('username'=>$var)); else return null; }
Base
1
public static function addViews($id) { $botlist = self::botlist(); $nom = 0; foreach($botlist as $bot) { if(preg_match("/{$bot}/", $_SERVER['HTTP_USER_AGENT'])) { $nom = 1+$nom; }else{ $nom = 0; } } if ($nom == 0) { # code... $sql = "UPDATE `posts` SET `views` = `views`+1 WHERE `id` = '{$id}' LIMIT 1"; $q = Db::query($sql); } }
Base
1
function scan_page($parent_id) { global $db; $sections = $db->selectObjects('section','parent=' . $parent_id); $ret = ''; foreach ($sections as $page) { $cLoc = serialize(expCore::makeLocation('container','@section' . $page->id)); $ret .= scan_container($cLoc, $page->id); $ret .= scan_page($page->id); } return $ret; }
Base
1
public function paramRules() { return array( 'title' => Yii::t('studio',$this->title), 'info' => Yii::t('studio',$this->info), 'modelRequired' => 'Contacts', 'options' => array( array( 'name'=>'listId', 'label'=>Yii::t('studio','List'), 'type'=>'link', 'linkType'=>'X2List', 'linkSource'=>Yii::app()->createUrl( CActiveRecord::model('X2List')->autoCompleteSource ) ), )); }
Base
1
static function displayname() { return gt("e-Commerce Category Manager"); }
Class
2
function searchName() { return gt("Calendar Event"); }
Class
2
public function store($zdb) { $data = array( 'short_label' => $this->short, 'long_label' => $this->long ); try { if ($this->id !== null && $this->id > 0) { $update = $zdb->update(self::TABLE); $update->set($data)->where( self::PK . '=' . $this->id ); $zdb->execute($update); } else { $insert = $zdb->insert(self::TABLE); $insert->values($data); $add = $zdb->execute($insert); if (!$add->count() > 0) { Analog::log('Not stored!', Analog::ERROR); return false; } $this->id = $zdb->getLastGeneratedValue($this); } return true; } catch (Throwable $e) { Analog::log( 'An error occurred storing title: ' . $e->getMessage() . "\n" . print_r($data, true), Analog::ERROR ); throw $e; } }
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
function _makeExtra($value, $title = '') { global $THIS_RET; if ($THIS_RET['WITH_TEACHER_ID']) $return .= ''._with.':&nbsp;' . GetTeacher($THIS_RET['WITH_TEACHER_ID']) . '<BR>'; if ($THIS_RET['NOT_TEACHER_ID']) $return .= ''._notWith.':&nbsp;' . GetTeacher($THIS_RET['NOT_TEACHER_ID']) . '<BR>'; if ($THIS_RET['WITH_PERIOD_ID']) $return .= ''._on.':&nbsp;' . GetPeriod($THIS_RET['WITH_PERIOD_ID']) . '<BR>'; if ($THIS_RET['NOT_PERIOD_ID']) $return .= ''._notOn.':&nbsp;' . GetPeriod($THIS_RET['NOT_PERIOD_ID']) . '<BR>'; if ($THIS_RET['PRIORITY']) $return .= ''._priority.':&nbsp;' . $THIS_RET['PRIORITY'] . '<BR>'; if ($THIS_RET['MARKING_PERIOD_ID']) $return .= ''._markingPeriod.':&nbsp;' . GetMP($THIS_RET['MARKING_PERIOD_ID']) . '<BR>'; return $return; }
Base
1
public function testXForwarderForHeaderForForwardedRequests($xForwardedFor, $expected) { $this->setNextResponse(); $server = array('REMOTE_ADDR' => '10.0.0.1'); if (false !== $xForwardedFor) { $server['HTTP_X_FORWARDED_FOR'] = $xForwardedFor; } $this->request('GET', '/', $server); $this->assertEquals($expected, $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For')); }
Class
2
foreach($fields as $field) { if(substr($key, 0, strlen($field.'-'))==$field.'-') { $this->dictionary[substr($key, strlen($field.'-'))][$field] = $value; } }
Base
1
public function setting($name, $value=NULL) { global $DB; global $website; $DB->query( 'SELECT * FROM nv_settings WHERE type = "user" AND user = '.protect($this->id).' AND website = '.protect($website->id).' AND name = '.protect($name) ); $setting = $DB->first(); if(!isset($value)) { if(!empty($setting)) $value = $setting->value; } else { // replace setting value if(empty($setting)) { $DB->execute(' INSERT INTO nv_settings (id, website, type, user, name, value) VALUES (:id, :website, :type, :user, :name, :value) ', array( ':id' => 0, ':website' => $website->id, ':type' => "user", ':user' => $this->id, ':name' => $name, ':value' => $value )); } else { $DB->execute(' UPDATE nv_settings SET value = :value WHERE id = :id ', array( ':id' => $setting->id, ':value' => $value )); } } return $value; }
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']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login']; // $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval']; // $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification']; // $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email']; if (empty($this->params['id'])) { flash('error', gt('No ID supplied for comment to approve')); expHistory::back(); } $comment = new expComment($this->params['id']); assign_to_template(array( 'comment'=>$comment )); }
Base
1
public function testPinCommentAction() { $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $this->assertAccessIsGranted($client, '/admin/customer/1/details'); $form = $client->getCrawler()->filter('form[name=customer_comment_form]')->form(); $client->submit($form, [ 'customer_comment_form' => [ 'message' => 'Blah foo bar', ] ]); $this->assertIsRedirect($client, $this->createUrl('/admin/customer/1/details')); $client->followRedirect(); $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text'); self::assertStringContainsString('Blah foo bar', $node->html()); $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text a.btn.active'); self::assertEquals(0, $node->count()); $comments = $this->getEntityManager()->getRepository(CustomerComment::class)->findAll(); $id = $comments[0]->getId(); $this->request($client, '/admin/customer/' . $id . '/comment_pin'); $this->assertIsRedirect($client, $this->createUrl('/admin/customer/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/customer/' . $id . '/comment_pin'), $node->attr('href')); }
Compound
4
public function changeTableInfoAction() { $field = $_REQUEST['field']; if ($field == 'pma_null') { $this->response->addJSON('field_type', ''); $this->response->addJSON('field_collation', ''); $this->response->addJSON('field_operators', ''); $this->response->addJSON('field_value', ''); return; } $key = array_search($field, $this->_columnNames); $properties = $this->getColumnProperties($_REQUEST['it'], $key); $this->response->addJSON( 'field_type', htmlspecialchars($properties['type']) ); $this->response->addJSON('field_collation', $properties['collation']); $this->response->addJSON('field_operators', $properties['func']); $this->response->addJSON('field_value', $properties['value']); }
Base
1
public static function dropdown($vars){ if(is_array($vars)){ //print_r($vars); $name = $vars['name']; $where = "WHERE "; if(isset($vars['type'])) { $where .= " `type` = '{$vars['type']}' AND "; }else{ $where .= " "; } $where .= " `status` = '1' "; $order_by = "ORDER BY "; if(isset($vars['order_by'])) { $order_by .= " {$vars['order_by']} "; }else{ $order_by .= " `name` "; } if (isset($vars['sort'])) { $sort = " {$vars['sort']}"; }else{ $sort = 'ASC'; } } $cat = Db::result("SELECT * FROM `posts` {$where} {$order_by} {$sort}"); $num = Db::$num_rows; $drop = "<select name=\"{$name}\" class=\"form-control\"><option></option>"; if($num > 0){ foreach ($cat as $c) { # code... // if($c->parent == ''){ if(isset($vars['selected']) && $c->id == $vars['selected']) $sel = "SELECTED"; else $sel = ""; $drop .= "<option value=\"{$c->id}\" $sel style=\"padding-left: 10px;\">{$c->title}</option>"; // foreach ($cat as $c2) { // # code... // if($c2->parent == $c->id){ // if(isset($vars['selected']) && $c2->id == $vars['selected']) $sel = "SELECTED"; else $sel = ""; // $drop .= "<option value=\"{$c2->id}\" $sel style=\"padding-left: 10px;\">&nbsp;&nbsp;&nbsp;{$c2->name}</option>"; // } // } // } } } $drop .= "</select>"; return $drop; }
Compound
4
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), )); }
Class
2
function read_cache( $cache_id, $check = false ) { global $cms_db; if ( $cache_id && $this->use_cache ) { if ( !$this->cache_db ) $this->cache_db = new DB_cms; $return = false; $sql = "SELECT val FROM " . $cms_db['db_cache'] . " WHERE name = '" . $this->cache_name . "' AND sid = '" . $cache_id . "'"; if ( !$this->cache_db->query( $sql ) ) return; $oldmode = $this->cache_db->get_fetch_mode(); $this->cache_db->set_fetch_mode( 'DB_FETCH_ASSOC' ); if( $this->cache_db->next_record() ) { if ( $check ) { $return = true; } else { $cache_pre = $this->cache_db->this_record(); $cache_val = $cache_pre['val']; $cache = unserialize( stripslashes( $cache_val ) ); if ( is_array( $cache ) ) { $this->cache = $cache; $return = true; } } } $this->cache_db->set_fetch_mode( $oldmode ); return $return; } else $this->cache_mode = ''; }
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
public function getPrintAndMailLink($icmsObj) { global $icmsConfig, $impresscms; $ret = ''; /* $printlink = $this->handler->_moduleUrl . "print.php?" . $this->handler->keyName . "=" . $icmsObj->getVar($this->handler->keyName); $js = "javascript:openWithSelfMain('" . $printlink . "', 'smartpopup', 700, 519);"; $printlink = '<a href="' . $js . '"><img src="' . ICMS_IMAGES_SET_URL . '/actions/fileprint.png" alt="" style="vertical-align: middle;"/></a>'; $icmsModule = icms_getModuleInfo($icmsObj->handler->_moduleName); $link = $impresscms->urls['full'](); $mid = $icmsModule->getVar('mid'); $friendlink = "<a href=\"javascript:openWithSelfMain('".SMARTOBJECT_URL."sendlink.php?link=" . $link . "&amp;mid=" . $mid . "', ',',',',',','sendmessage', 674, 500);\"><img src=\"".SMARTOBJECT_IMAGES_ACTIONS_URL . "mail_send.png\" alt=\"" . _CO_ICMS_EMAIL . "\" title=\"" . _CO_ICMS_EMAIL . "\" style=\"vertical-align: middle;\"/></a>"; $ret = '<span id="smartobject_print_button">' . $printlink . "&nbsp;</span>" . '<span id="smartobject_mail_button">' . $friendlink . '</span>'; */ return $ret; }
Base
1
private function updateDeadline() { try { $due_date = self::getDueDate($this->zdb, $this->_member); if ($due_date != '') { $date_fin_update = $due_date; } else { $date_fin_update = new Expression('NULL'); } $update = $this->zdb->update(Adherent::TABLE); $update->set( array('date_echeance' => $date_fin_update) )->where( Adherent::PK . '=' . $this->_member ); $this->zdb->execute($update); return true; } catch (Throwable $e) { Analog::log( 'An error occurred updating member ' . $this->_member . '\'s deadline |' . $e->getMessage(), Analog::ERROR ); throw $e; } }
Base
1
public function confirm() { $task = $this->getTask(); $link = $this->getTaskLink(); $this->response->html($this->template->render('task_internal_link/remove', array( 'link' => $link, 'task' => $task, ))); }
Class
2
static function description() { return gt("This module is for managing categories in your store."); }
Base
1
list($h, $m) = explode('.', $row['RunAt']); $main .= '<div style="' . $extra_css . '" class="phoromatic_overview_box">'; $main .= '<h1><a href="?schedules/' . $row['ScheduleID'] . '">' . $row['Title'] . '</a></h1>'; if(!empty($systems_for_schedule)) { if($row['RunAt'] > date('H.i')) { $run_in_future = true; $main .= '<h3>Runs In ' . pts_strings::format_time((($h * 60) + $m) - ((date('H') * 60) + date('i')), 'MINUTES') . '</h3>'; } else { $run_in_future = false; $main .= '<h3>Triggered ' . pts_strings::format_time(max(1, (date('H') * 60) + date('i') - (($h * 60) + $m)), 'MINUTES') . ' Ago</h3>'; } } foreach($systems_for_schedule as $system_id) { $pprid = self::result_match($row['ScheduleID'], $system_id, date('Y-m-d')); if($pprid) $main .= '<a href="?result/' . $pprid . '">'; $main .= phoromatic_server::system_id_to_name($system_id); if($pprid) $main .= '</a>'; else if(!$run_in_future) { $sys_info = self::system_info($system_id); $last_comm_diff = time() - strtotime($sys_info['LastCommunication']); $main .= ' <sup><a href="?systems/' . $system_id . '">'; if($last_comm_diff > 3600) { $main .= '<strong>Last Communication: ' . pts_strings::format_time($last_comm_diff, 'SECONDS', true, 60) . ' Ago</strong>'; } else { $main .= $sys_info['CurrentTask']; } $main .= '</a></sup>'; } $main .= '<br />'; } $main .= '</div>'; } $main .= '</div>'; $main .= '</div>'; echo '<div id="pts_phoromatic_main_area">' . $main . '</div>'; //echo phoromatic_webui_main($main, phoromatic_webui_right_panel_logged_in()); echo phoromatic_webui_footer(); }
Base
1
public function urlProvider() { return array( array('http://till:[email protected]/', $this->getCmd(" --username 'till' --password 'test' ")), array('http://svn.apache.org/', ''), array('svn://[email protected]', $this->getCmd(" --username 'johndoe' --password '' ")), ); }
Class
2
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
Base
1
public function show() { $task = $this->getTask(); $subtask = $this->getSubtask(); $this->response->html($this->template->render('subtask_converter/show', array( 'subtask' => $subtask, 'task' => $task, ))); }
Class
2
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 remove() { $this->checkCSRFParam(); $project = $this->getProject(); $tag_id = $this->request->getIntegerParam('tag_id'); $tag = $this->tagModel->getById($tag_id); if ($tag['project_id'] != $project['id']) { throw new AccessForbiddenException(); } if ($this->tagModel->remove($tag_id)) { $this->flash->success(t('Tag removed successfully.')); } else { $this->flash->failure(t('Unable to remove this tag.')); } $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); }
Base
1
private static function dumpParsedRefs( $parser, $label ) { // if (!preg_match("/Query Q/",$parser->mTitle->getText())) return ''; echo '<pre>parser mLinks: '; ob_start(); var_dump( $parser->getOutput()->mLinks ); $a = ob_get_contents(); ob_end_clean(); echo htmlspecialchars( $a, ENT_QUOTES ); echo '</pre>'; echo '<pre>parser mTemplates: '; ob_start(); var_dump( $parser->getOutput()->mTemplates ); $a = ob_get_contents(); ob_end_clean(); echo htmlspecialchars( $a, ENT_QUOTES ); echo '</pre>'; }
Class
2
function __construct() { $this->render_menu_page(); }
Base
1
function process_subsections($parent_section, $subtpl) { global $db, $router; $section = new stdClass(); $section->parent = $parent_section->id; $section->name = $subtpl->name; $section->sef_name = $router->encode($section->name); $section->subtheme = $subtpl->subtheme; $section->active = $subtpl->active; $section->public = $subtpl->public; $section->rank = $subtpl->rank; $section->page_title = $subtpl->page_title; $section->keywords = $subtpl->keywords; $section->description = $subtpl->description; $section->id = $db->insertObject($section, 'section'); self::process_section($section, $subtpl); }
Class
2
function get_current_tab() { $tab_keys = array_keys($this->menu_tabs); $tab = isset( $_GET['tab'] ) ? sanitize_text_field($_GET['tab']) : $tab_keys[0]; return $tab; }
Base
1
private static function executeTag( $input, array $args, Parser $parser, PPFrame $frame ) { // entry point for user tag <dpl> or <DynamicPageList> // create list and do a recursive parse of the output $parse = new \DPL\Parse(); if ( \DPL\Config::getSetting( 'recursiveTagParse' ) ) { $input = $parser->recursiveTagParse( $input, $frame ); } $text = $parse->parse( $input, $parser, $reset, $eliminate, true ); if ( isset( $reset['templates'] ) && $reset['templates'] ) { // we can remove the templates by save/restore $saveTemplates = $parser->getOutput()->mTemplates; } if ( isset( $reset['categories'] ) && $reset['categories'] ) { // we can remove the categories by save/restore $saveCategories = $parser->getOutput()->mCategories; } if ( isset( $reset['images'] ) && $reset['images'] ) { // we can remove the images by save/restore $saveImages = $parser->getOutput()->mImages; } $parsedDPL = $parser->recursiveTagParse( $text ); if ( isset( $reset['templates'] ) && $reset['templates'] ) { $parser->getOutput()->mTemplates = $saveTemplates; } if ( isset( $reset['categories'] ) && $reset['categories'] ) { $parser->getOutput()->mCategories = $saveCategories; } if ( isset( $reset['images'] ) && $reset['images'] ) { $parser->getOutput()->mImages = $saveImages; } return $parsedDPL; }
Class
2
$body = str_replace(array("\n"), "<br />", $body); } else { // It's going elsewhere (doesn't like quoted-printable) $body = str_replace(array("\n"), " -- ", $body); } $title = $items[$i]->title; $msg .= "BEGIN:VEVENT\n"; $msg .= $dtstart . $dtend; $msg .= "UID:" . $items[$i]->date_id . "\n"; $msg .= "DTSTAMP:" . date("Ymd\THis", time()) . "Z\n"; if ($title) { $msg .= "SUMMARY:$title\n"; } if ($body) { $msg .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" . $body . "\n"; } // if($link_url) { $msg .= "URL: $link_url\n";} if (!empty($this->config['usecategories'])) { if (!empty($items[$i]->expCat[0]->title)) { $msg .= "CATEGORIES:".$items[$i]->expCat[0]->title."\n"; } else { $msg .= "CATEGORIES:".$this->config['uncat']."\n"; } } $msg .= "END:VEVENT\n"; }
Base
1
private function getCategory() { $category = $this->categoryModel->getById($this->request->getIntegerParam('category_id')); if (empty($category)) { throw new PageNotFoundException(); } return $category; }
Base
1
public function __construct(){ }
Compound
4
public function update_version() { // get the current version $hv = new help_version(); $current_version = $hv->find('first', 'is_current=1'); // check to see if the we have a new current version and unset the old current version. if (!empty($this->params['is_current'])) { // $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0'); help_version::clearHelpVersion(); } expSession::un_set('help-version'); // save the version $id = empty($this->params['id']) ? null : $this->params['id']; $version = new help_version(); // if we don't have a current version yet so we will force this one to be it if (empty($current_version->id)) $this->params['is_current'] = 1; $version->update($this->params); // if this is a new version we need to copy over docs if (empty($id)) { self::copydocs($current_version->id, $version->id); } // let's update the search index to reflect the current help version searchController::spider(); flash('message', gt('Saved help version').' '.$version->version); expHistory::back(); }
Class
2
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
$result = $search->getSearchResults($item->query, false, true); if(empty($result) && !in_array($item->query, $badSearchArr)) { $badSearchArr[] = $item->query; $badSearch[$ctr2]['query'] = $item->query; $badSearch[$ctr2]['count'] = $db->countObjects("search_queries", "query='{$item->query}'"); $ctr2++; } } //Check if the user choose from the dropdown if(!empty($user_default)) { if($user_default == $anonymous) { $u_id = 0; } else { $u_id = $user_default; } $where .= "user_id = {$u_id}"; } //Get all the search query records $records = $db->selectObjects('search_queries', $where); for ($i = 0, $iMax = count($records); $i < $iMax; $i++) { if(!empty($records[$i]->user_id)) { $u = user::getUserById($records[$i]->user_id); $records[$i]->user = $u->firstname . ' ' . $u->lastname; } } $page = new expPaginator(array( 'records' => $records, 'where'=>1, 'model'=>'search_queries', 'limit'=>(isset($this->config['limit']) && $this->config['limit'] != '') ? 10 : $this->config['limit'], 'order'=>empty($this->config['order']) ? 'timestamp' : $this->config['order'], 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1), 'controller'=>$this->baseclassname, 'action'=>$this->params['action'], 'columns'=>array( 'ID'=>'id', gt('Query')=>'query', gt('Timestamp')=>'timestamp', gt('User')=>'user_id', ), )); $uname['id'] = implode($uname['id'],','); $uname['name'] = implode($uname['name'],','); assign_to_template(array( 'page'=>$page, 'users'=>$uname, 'user_default' => $user_default, 'badSearch' => $badSearch )); }
Base
1
public function __invoke(Request $request) { $this->authorize('manage modules'); $path = ModuleInstaller::unzip($request->module, $request->path); return response()->json([ 'success' => true, 'path' => $path ]); }
Base
1
$db->updateObject($value, 'section'); } $db->updateObject($moveSec, 'section'); //handle re-ranking of previous parent $oldSiblings = $db->selectObjects("section", "parent=" . $oldParent . " AND rank>" . $oldRank . " ORDER BY rank"); $rerank = 1; foreach ($oldSiblings as $value) { if ($value->id != $moveSec->id) { $value->rank = $rerank; $db->updateObject($value, 'section'); $rerank++; } } if ($oldParent != $moveSec->parent) { //we need to re-rank the children of the parent that the moving section has just left $childOfLastMove = $db->selectObjects("section", "parent=" . $oldParent . " ORDER BY rank"); for ($i = 0, $iMax = count($childOfLastMove); $i < $iMax; $i++) { $childOfLastMove[$i]->rank = $i; $db->updateObject($childOfLastMove[$i], 'section'); } } } } self::checkForSectionalAdmins($move); expSession::clearAllUsersSessionCache('navigation'); }
Base
1
$link = str_replace(URL_FULL, '', makeLink(array('section' => $section->id)));
Base
1
protected function decodeData($data) { if ($this->base64encode) { if (is_string($data)) { if (($data = base64_decode($data)) !== false) { $data = @unserialize($data); } else { $data = null; } } else { $data = null; } } return $data; }
Base
1
$this->markTestSkipped('Function openssl_random_pseudo_bytes need LibreSSL version >=2.1.5 or Windows system on server'); } } static::$functions = $functions; // test various string lengths for ($length = 1; $length < 64; $length++) { $key1 = $this->security->generateRandomKey($length); $this->assertInternalType('string', $key1); $this->assertEquals($length, strlen($key1)); $key2 = $this->security->generateRandomKey($length); $this->assertInternalType('string', $key2); $this->assertEquals($length, strlen($key2)); if ($length >= 7) { // avoid random test failure, short strings are likely to collide $this->assertNotEquals($key1, $key2); } } // test for /dev/urandom, reading larger data to see if loop works properly $length = 1024 * 1024; $key1 = $this->security->generateRandomKey($length); $this->assertInternalType('string', $key1); $this->assertEquals($length, strlen($key1)); $key2 = $this->security->generateRandomKey($length); $this->assertInternalType('string', $key2); $this->assertEquals($length, strlen($key2)); $this->assertNotEquals($key1, $key2); // force /dev/urandom reading loop to deal with chunked data // the above test may have read everything in one run. // not sure if this can happen in real life but if it does // we should be prepared static::$fopen = fopen('php://memory', 'rwb'); $length = 1024 * 1024; $key1 = $this->security->generateRandomKey($length); $this->assertInternalType('string', $key1); $this->assertEquals($length, strlen($key1)); }
Class
2
public function __construct() { global $GLOBALS; }
Base
1
public function testSmtpConnect() { $this->Mail->SMTPDebug = 4; //Show connection-level errors $this->assertTrue($this->Mail->smtpConnect(), 'SMTP single connect failed'); $this->Mail->smtpClose(); $this->Mail->Host = "ssl://localhost:12345;tls://localhost:587;10.10.10.10:54321;localhost:12345;10.10.10.10"; $this->assertFalse($this->Mail->smtpConnect(), 'SMTP bad multi-connect succeeded'); $this->Mail->smtpClose(); $this->Mail->Host = "localhost:12345;10.10.10.10:54321;" . $_REQUEST['mail_host']; $this->assertTrue($this->Mail->smtpConnect(), 'SMTP multi-connect failed'); $this->Mail->smtpClose(); $this->Mail->Host = " localhost:12345 ; " . $_REQUEST['mail_host'] . ' '; $this->assertTrue($this->Mail->smtpConnect(), 'SMTP hosts with stray spaces failed'); $this->Mail->smtpClose(); $this->Mail->Host = $_REQUEST['mail_host']; //Need to pick a harmless option so as not cause problems of its own! socket:bind doesn't work with Travis-CI $this->assertTrue( $this->Mail->smtpConnect(array('ssl' => array('verify_depth' => 10))), 'SMTP connect with options failed' ); }
Class
2
function edit() { global $user; /* The global constants can be overriden by passing appropriate params */ //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet $require_login = empty($this->params['require_login']) ? SIMPLENOTE_REQUIRE_LOGIN : $this->params['require_login']; $require_approval = empty($this->params['require_approval']) ? SIMPLENOTE_REQUIRE_APPROVAL : $this->params['require_approval']; $require_notification = empty($this->params['require_notification']) ? SIMPLENOTE_REQUIRE_NOTIFICATION : $this->params['require_notification']; $notification_email = empty($this->params['notification_email']) ? SIMPLENOTE_NOTIFICATION_EMAIL : $this->params['notification_email']; if (empty($this->params['formtitle'])) { if (empty($this->params['id'])) { $formtitle = gt("Add New Note"); } else { $formtitle = gt("Edit Note"); } } else { $formtitle = $this->params['formtitle']; } $id = empty($this->params['id']) ? null : $this->params['id']; $simpleNote = new expSimpleNote($id); //FIXME here is where we might sanitize the note before displaying/editing it assign_to_template(array( 'simplenote'=>$simpleNote, 'user'=>$user, 'require_login'=>$require_login, 'require_approval'=>$require_approval, 'require_notification'=>$require_notification, 'notification_email'=>$notification_email, 'formtitle'=>$formtitle, 'content_type'=>$this->params['content_type'], 'content_id'=>$this->params['content_id'], 'tab'=>empty($this->params['tab'])?0:$this->params['tab'] )); }
Base
1
public function update() { global $DB; $ok = $DB->execute(' UPDATE nv_menus SET codename = :codename, icon = :icon, lid = :lid, notes = :notes, functions = :functions, enabled = :enabled WHERE id = :id', array( 'id' => $this->id, 'codename' => value_or_default($this->codename, ""), 'icon' => value_or_default($this->icon, ""), 'lid' => value_or_default($this->lid, 0), 'notes' => value_or_default($this->notes, ""), 'functions' => json_encode($this->functions), 'enabled' => value_or_default($this->enabled, 0) ) ); if(!$ok) throw new Exception($DB->get_last_error()); return true; }
Base
1
protected function AddAnAddress($kind, $address, $name = '') { if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) { $this->SetError($this->Lang('Invalid recipient array').': '.$kind); if ($this->exceptions) { throw new phpmailerException('Invalid recipient array: ' . $kind); } if ($this->SMTPDebug) { $this->edebug($this->Lang('Invalid recipient array').': '.$kind); } return false; } $address = trim($address); $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim if (!$this->ValidateAddress($address)) { $this->SetError($this->Lang('invalid_address').': '. $address); if ($this->exceptions) { throw new phpmailerException($this->Lang('invalid_address').': '.$address); } if ($this->SMTPDebug) { $this->edebug($this->Lang('invalid_address').': '.$address); } return false; } if ($kind != 'Reply-To') { if (!isset($this->all_recipients[strtolower($address)])) { array_push($this->$kind, array($address, $name)); $this->all_recipients[strtolower($address)] = true; return true; } } else { if (!array_key_exists(strtolower($address), $this->ReplyTo)) { $this->ReplyTo[strtolower($address)] = array($address, $name); return true; } } return false; }
Base
1
public function testFirstTrustedProxyIsSetAsRemote() { $expectedSubRequest = Request::create('/'); $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); $expectedSubRequest->server->set('REMOTE_ADDR', '1.1.1.1'); if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) { $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); } Request::setTrustedProxies(array('1.1.1.1')); $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); $request = Request::create('/'); $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"'); $strategy->render('/', $request); Request::setTrustedProxies(array()); }
Class
2
public function delete($id) { $this->CRUD->delete($id); $responsePayload = $this->CRUD->getResponsePayload(); if (!empty($responsePayload)) { return $responsePayload; } $this->set('metaGroup', 'Trust Circles'); }
Class
2
protected function renderText ($field, $makeLinks, $textOnly, $encode) { $fieldName = $field->fieldName; $value = preg_replace("/(\<br ?\/?\>)|\n/"," ",$this->owner->$fieldName); return Yii::app()->controller->convertUrls($this->render ($value, $encode)); }
Class
2
public function hasHeader($header) { return isset($this->headers[strtolower($header)]); }
Base
1
public function getQueryGroupby() { return ''; }
Base
1
public function __construct() { $this->pop_conn = 0; $this->connected = false; $this->error = null; }
Base
1
protected function parseChunkedRequest(Request $request) { $totalChunkCount = $request->get('dztotalchunkcount'); $index = $request->get('dzchunkindex'); $last = ((int) $index + 1) === (int) $totalChunkCount; $uuid = $request->get('dzuuid'); /** * @var UploadedFile */ $file = $request->files->get('file')->getClientOriginalName(); $orig = $file; return [$last, $uuid, $index, $orig]; }
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']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login']; // $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval']; // $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification']; // $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email']; if (empty($this->params['id'])) { flash('error', gt('No ID supplied for comment to approve')); expHistory::back(); } $comment = new expComment($this->params['id']); assign_to_template(array( 'comment'=>$comment )); }
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
public function remove() { $this->checkCSRFParam(); $project = $this->getProject(); $tag_id = $this->request->getIntegerParam('tag_id'); $tag = $this->tagModel->getById($tag_id); if ($tag['project_id'] != $project['id']) { throw new AccessForbiddenException(); } if ($this->tagModel->remove($tag_id)) { $this->flash->success(t('Tag removed successfully.')); } else { $this->flash->failure(t('Unable to remove this tag.')); } $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); }
Base
1
public function __invoke(Request $request, Expense $expense) { $this->authorize('update', $expense); $data = json_decode($request->attachment_receipt); if ($data) { if ($request->type === 'edit') { $expense->clearMediaCollection('receipts'); } $expense->addMediaFromBase64($data->data) ->usingFileName($data->name) ->toMediaCollection('receipts'); } return response()->json([ 'success' => 'Expense receipts uploaded successfully', ], 200); }
Base
1
public static function setArray( $arg ) { $numargs = count( $arg ); if ( $numargs < 5 ) { return ''; } $var = trim( $arg[2] ); $value = $arg[3]; $delimiter = $arg[4]; if ( $var == '' ) { return ''; } if ( $value == '' ) { self::$memoryArray[$var] = []; return; } if ( $delimiter == '' ) { self::$memoryArray[$var] = [ $value ]; return; } if ( 0 !== strpos( $delimiter, '/' ) || ( strlen( $delimiter ) - 1 ) !== strrpos( $delimiter, '/' ) ) { $delimiter = '/\s*' . $delimiter . '\s*/'; } self::$memoryArray[$var] = preg_split( $delimiter, $value ); return "value={$value}, delimiter={$delimiter}," . count( self::$memoryArray[$var] ); }
Class
2
public static function sitemap() { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/sitemap".GX_URL_PREFIX; break; default: # code... $url = Options::get('siteurl')."/index.php?page=sitemap"; break; } return $url; }
Base
1
protected function assertCsvUploaded($csv) { $uploadedPath = implode(DIRECTORY_SEPARATOR, array( Yii::app()->basePath, 'data', 'data.csv' )); $this->assertFileExists ($uploadedPath); $this->assertFileEquals ($csv, $uploadedPath); }
Class
2
private function mail_passthru($to, $subject, $body, $header, $params) { if ( ini_get('safe_mode') || !($this->UseSendmailOptions) ) { $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header); } else { $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header, $params); } return $rt; }
Class
2
public function testGetFilteredEventsDataProvider () { TestingAuxLib::loadX2NonWebUser (); TestingAuxLib::suLogin ('testuser'); Yii::app()->settings->historyPrivacy = null; $profile = Profile::model()->findByAttributes(array('username' => 'testuser')); $retVal = Events::getFilteredEventsDataProvider ($profile, true, null, false); $dataProvider = $retVal['dataProvider']; $events = $dataProvider->getData (); $expectedEvents = Events::getEvents (0, 0, count ($events), $profile); // verify events from getData $this->assertEquals ( Yii::app()->db->createCommand (" select id from x2_events where user='testuser' or visibility order by timestamp desc, id desc ")->queryColumn (), array_map ( function ($event) { return $event->id; }, $expectedEvents['events'] ) ); // ensure that getFilteredEventsDataProvider returns same events as getData $this->assertEquals ( array_map ( function ($event) { return $event->id; }, $expectedEvents['events'] ), array_map ( function ($event) { return $event->id; }, $events ) ); TestingAuxLib::restoreX2WebUser (); }
Class
2
foreach ($day as $extevent) { $event_cache = new stdClass(); $event_cache->feed = $extgcalurl; $event_cache->event_id = $extevent->event_id; $event_cache->title = $extevent->title; $event_cache->body = $extevent->body; $event_cache->eventdate = $extevent->eventdate->date; if (isset($extevent->dateFinished) && $extevent->dateFinished != -68400) $event_cache->dateFinished = $extevent->dateFinished; if (isset($extevent->eventstart)) $event_cache->eventstart = $extevent->eventstart; if (isset($extevent->eventend)) $event_cache->eventend = $extevent->eventend; if (isset($extevent->is_allday)) $event_cache->is_allday = $extevent->is_allday; $found = false; if ($extevent->eventdate->date < $start) // prevent duplicating events crossing month boundaries $found = $db->selectObject('event_cache','feed="'.$extgcalurl.'" AND event_id="'.$event_cache->event_id.'" AND eventdate='.$event_cache->eventdate); if (!$found) $db->insertObject($event_cache,'event_cache'); }
Base
1
private function runCallback() { foreach ($this->records as &$record) { if (isset($record->ref_type)) { $refType = $record->ref_type; if (class_exists($record->ref_type)) { $type = new $refType(); $classinfo = new ReflectionClass($type); if ($classinfo->hasMethod('paginationCallback')) { $item = new $type($record->original_id); $item->paginationCallback($record); } } } } }
Base
1
public function check(&$params){ $tags = $this->config['options']['tags']['value']; $tags = is_array($tags) ? $tags : Tags::parseTags($tags, true); if(!empty($tags) && isset($params['tags'])){ // Check passed params to be sure they're set if(!is_array($params['tags'])){ $params['tags'] = explode(',', $params['tags']); } $params['tags'] = array_map(function($item){ return preg_replace('/^#/','', $item); }, $params['tags']); // must have at least 1 tag in the list: if(count(array_intersect($params['tags'], $tags)) > 0){ return $this->checkConditions($params); }else{ return array(false, Yii::t('studio','No tags on the record matched those in the tag trigger criteria.')); } }else{ // config is invalid or record has no tags (tags are not optional) return array(false, empty($tags) ? Yii::t('studio','No tags in the trigger criteria!') : Yii::t('studio','Tags parameter missing!')); } }
Base
1
function manage() { global $db, $router, $user; expHistory::set('manageable', $router->params); assign_to_template(array( 'canManageStandalones' => self::canManageStandalones(), 'sasections' => $db->selectObjects('section', 'parent=-1'), 'user' => $user, // 'canManagePagesets' => $user->isAdmin(), // 'templates' => $db->selectObjects('section_template', 'parent=0'), )); }
Class
2
function update() { parent::update(); expSession::clearAllUsersSessionCache('navigation'); }
Class
2
} elseif ($this->isValidOrderKey($o)) { $this->orderKey[] = '`' . $o . '`'; } } }
Base
1
public function upload() { // upload the file, but don't save the record yet... if ($this->params['resize'] != 'false') { $maxwidth = $this->params['max_width']; } else { $maxwidth = null; } $file = expFile::fileUpload('Filedata',false,false,null,null,$maxwidth); // since most likely this function will only get hit via flash in YUI Uploader // and since Flash can't pass cookies, we lose the knowledge of our $user // so we're passing the user's ID in as $_POST data. We then instantiate a new $user, // and then assign $user->id to $file->poster so we have an audit trail for the upload if (is_object($file)) { $resized = !empty($file->resized) ? true : false; $user = new user($this->params['usrid']); $file->poster = $user->id; $file->posted = $file->last_accessed = time(); $file->save(); if (!empty($this->params['cat'])) { $expcat = new expCat($this->params['cat']); $params['expCat'][0] = $expcat->id; $file->update($params); } // a echo so YUI Uploader is notified of the function's completion if ($resized) { echo gt('File resized and then saved'); } else { echo gt('File saved'); } } else { echo gt('File was NOT uploaded!'); // flash('error',gt('File was not uploaded!')); } }
Base
1
public function update() { $project = $this->getProject(); $tag_id = $this->request->getIntegerParam('tag_id'); $tag = $this->tagModel->getById($tag_id); $values = $this->request->getValues(); list($valid, $errors) = $this->tagValidator->validateModification($values); if ($tag['project_id'] != $project['id']) { throw new AccessForbiddenException(); } if ($valid) { if ($this->tagModel->update($values['id'], $values['name'])) { $this->flash->success(t('Tag updated successfully.')); } else { $this->flash->failure(t('Unable to update this tag.')); } $this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id']))); } else { $this->edit($values, $errors); } }
Base
1
public function defaultCurrency(Request $request, TransactionCurrency $currency) { app('preferences')->set('currencyPreference', $currency->code); app('preferences')->mark(); Log::channel('audit')->info(sprintf('Make %s the default currency.', $currency->code)); $this->repository->enable($currency); $request->session()->flash('success', (string) trans('firefly.new_default_currency', ['name' => $currency->name])); return redirect(route('currencies.index')); }
Compound
4
public function manage_messages() { expHistory::set('manageable', $this->params); $page = new expPaginator(array( 'model'=>'order_status_messages', 'where'=>1, 'limit'=>10, 'order'=>'body', 'page'=>(isset($this->params['page']) ? $this->params['page'] : 1), 'controller'=>$this->params['controller'], 'action'=>$this->params['action'], //'columns'=>array('Name'=>'title') )); //eDebug($page); assign_to_template(array( 'page'=>$page )); }
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