code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
private function renderInvoice(InvoiceQuery $query, Request $request) { // use the current request locale as fallback, if no translation was configured if (null !== $query->getTemplate() && null === $query->getTemplate()->getLanguage()) { $query->getTemplate()->setLanguage($request->getLocale()); } try { $invoices = $this->service->createInvoices($query, $this->dispatcher); $this->flashSuccess('action.update.success'); if (\count($invoices) === 1) { return $this->redirectToRoute('admin_invoice_list', ['id' => $invoices[0]->getId()]); } return $this->redirectToRoute('admin_invoice_list'); } catch (Exception $ex) { $this->flashUpdateException($ex); } return $this->redirectToRoute('invoice'); }
Base
1
public function lists($column, $key = null) { $select = is_null($key) ? [$column] : [$column, $key]; if (!is_null($this->cacheMinutes)) { $results = $this->getCached($select); } else { $results = $this->getFresh($select); } $collection = new Collection($results); return $collection->lists($column, $key); }
Base
1
function remove() { global $db; $section = $db->selectObject('section', 'id=' . $this->params['id']); if ($section) { section::removeLevel($section->id); $db->decrement('section', 'rank', 1, 'rank > ' . $section->rank . ' AND parent=' . $section->parent); $section->parent = -1; $db->updateObject($section, 'section'); expSession::clearAllUsersSessionCache('navigation'); expHistory::back(); } else { notfoundController::handle_not_authorized(); } }
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
public function update_version() { // get the current version $hv = new help_version(); $current_version = $hv->find('first', 'is_current=1'); // check to see if the we have a new current version and unset the old current version. if (!empty($this->params['is_current'])) { // $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0'); help_version::clearHelpVersion(); } expSession::un_set('help-version'); // save the version $id = empty($this->params['id']) ? null : $this->params['id']; $version = new help_version(); // if we don't have a current version yet so we will force this one to be it if (empty($current_version->id)) $this->params['is_current'] = 1; $version->update($this->params); // if this is a new version we need to copy over docs if (empty($id)) { self::copydocs($current_version->id, $version->id); } // let's update the search index to reflect the current help version searchController::spider(); flash('message', gt('Saved help version').' '.$version->version); expHistory::back(); }
Base
1
foreach($image->expTag as $tag) { if (isset($used_tags[$tag->id])) { $used_tags[$tag->id]->count++; } else { $exptag = new expTag($tag->id); $used_tags[$tag->id] = $exptag; $used_tags[$tag->id]->count = 1; } }
Class
2
public function specialLogin( $error = null ) { $request = $this->getRequest(); $out = $this->getOutput(); $out->setPageTitle( wfMessage('soa2-login-title')->escaped() ); if ($error) { $this->error($error); } else if ( $request->wasPosted() && $request->getCheck( 'username' ) ) { $username = $request->getVal( 'username', '', ); if (!preg_match(SOA2_USERNAME_REGEX, $username)) { $this->specialLogin( wfMessage('soa2-invalid-username', $username)->plain() ); return; } if ($request->getCheck( 'token' )) { $this->doLogin( $request ); return; } $this->loginForm( $request ); return; } // Step 11 $out->addHTML(Html::openElement('form', [ 'method' => 'POST' ])); $out->addHTML(Html::rawElement('p', [], Html::label( wfMessage('soa2-scratch-username')->escaped(), 'soa2-username-input', ))); // Step 12 $out->addHTML(Html::rawElement('p', [], Html::input( 'username', $request->getVal('username', ''), 'text', [ 'id' => 'soa2-username-input' ] ))); $out->addHTML(Html::rawElement('p', [], Html::submitButton( wfMessage('soa2-next')->escaped(), [] ))); $out->addHTML(Html::closeElement('form')); }
Base
1
$output = sprintf( '<form action="%s" method="get">%s (%s): <input type="text" name="amount" value="%s"><br />%s<br /><textarea name="stripenote" cols="80" rows="2"></textarea><br /><input type="hidden" name="txid" value="%s"><button class="stripebutton">%s</button>%s</form>', $url, __( 'Amount', 'rsvpmaker' ), esc_attr( strtoupper( $vars['currency'] ) ), esc_attr( $vars['amount'] ), __('Note','rsvpmaker'), esc_attr( $idempotency_key ), __( 'Pay with Card' ), rsvpmaker_nonce('return') );
Base
1
$cLoc = serialize(expCore::makeLocation('container','@section' . $page->id)); $ret .= scan_container($cLoc, $page->id); $ret .= scan_page($page->id); }
Base
1
public function generateMessageFileName() { $time = microtime(true); return date('Ymd-His-', $time) . sprintf('%04d', (int) (($time - (int) $time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.eml'; }
Class
2
public function settings() { AuthUser::load(); if (!AuthUser::isLoggedIn()) { redirect(get_url('login')); } else if (!AuthUser::hasPermission('admin_edit')) { Flash::set('error', __('You do not have permission to access the requested page!')); redirect(get_url()); } $settings = Plugin::getAllSettings('file_manager'); if (!$settings) { Flash::set('error', 'Files - ' . __('unable to retrieve plugin settings.')); return; } $this->display('file_manager/views/settings', array('settings' => $settings)); }
Class
2
public function Delete() { // Delete "main" ticket $del_stmt = Database::prepare(' DELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `id` = :tid' ); Database::pexecute($del_stmt, array('tid' => $this->tid)); // Delete "answers" to ticket" $del_stmt = Database::prepare(' DELETE FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = :tid' ); Database::pexecute($del_stmt, array('tid' => $this->tid)); return true; }
Class
2
function delete_option_master() { global $db; $masteroption = new option_master($this->params['id']); // delete any implementations of this option master $db->delete('option', 'option_master_id='.$masteroption->id); $masteroption->delete('optiongroup_master_id=' . $masteroption->optiongroup_master_id); //eDebug($masteroption); expHistory::back(); }
Class
2
public function getDisplayName ($plural=true) { return Yii::t('workflow', '{process}', array( '{process}' => Modules::displayName($plural, 'Process'), )); }
Base
1
function execute( $par ) { $request = $this->getRequest(); $output = $this->getOutput(); $language = $this->getLanguage(); $output->setPageTitle( $this->msg( "confirmaccounts" )->escaped() ); $output->addModules('ext.scratchConfirmAccount.js'); $output->addModuleStyles('ext.scratchConfirmAccount.css'); $session = $request->getSession(); $this->setHeaders(); $this->checkReadOnly(); $this->showTopLinks(); //check permissions $user = $this->getUser(); if (!$user->isAllowed('createaccount')) { throw new PermissionsError('createaccount'); } if ($request->wasPosted()) { return $this->handleFormSubmission($request, $output, $session); } else if (strpos($par, wfMessage('scratch-confirmaccount-blocks')->text()) === 0) { return $this->blocksPage($par, $request, $output, $session); } else if (strpos($par, wfMessage('scratch-confirmaccount-requirements-bypasses-url')->text()) === 0) { $bypassPage = new RequirementsBypassPage($this); return $bypassPage->render(); } else if ($request->getText('username')) { return $this->searchByUsername($request->getText('username'), $request, $output); } else if (isset(statuses[$par])) { return $this->listRequestsByStatus($par, $output); } else if (ctype_digit($par)) { return requestPage($par, 'admin', $this, $request->getSession()); } else if (empty($par)) { return $this->defaultPage($output); } else { $output->showErrorPage('error', 'scratch-confirmaccount-nosuchrequest'); } }
Compound
4
public static function load_element_strings($node_type, $node_id, $savedOn="latest") { global $DB; // load all webdictionary history elements and keep only the latest $DB->query(' SELECT subtype, lang, text FROM nv_webdictionary_history WHERE node_type = '.protect($node_type).' AND node_id = '.protect($node_id).' ORDER BY date_created ASC' ); $data = $DB->result(); if(!is_array($data)) $data = array(); $dictionary = array(); foreach($data as $item) { $dictionary[$item->lang][$item->subtype] = $item->text; } return $dictionary; }
Base
1
$dt = date('Y-m-d', strtotime($match)); $sql = par_rep("/'$match'/", "'$dt'", $sql); } } if (substr($sql, 0, 6) == "BEGIN;") { $array = explode(";", $sql); foreach ($array as $value) { if ($value != "") { $user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']); if ($user_agent[0] == 'Mozilla') { $result = $connection->query($value); } if (!$result) { $user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']); if ($user_agent[0] == 'Mozilla') { $connection->query("ROLLBACK"); die(db_show_error($sql, _dbExecuteFailed, mysqli_error($connection))); } } } } } else { $user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']); if ($user_agent[0] == 'Mozilla') { $result = $connection->query($sql) or die(db_show_error($sql, _dbExecuteFailed, mysqli_error($connection))); } } break; }
Base
1
public static function canView($section) { global $db; if ($section == null) { return false; } if ($section->public == 0) { // Not a public section. Check permissions. return expPermissions::check('view', expCore::makeLocation('navigation', '', $section->id)); } else { // Is public. check parents. if ($section->parent <= 0) { // Out of parents, and since we are still checking, we haven't hit a private section. return true; } else { $s = $db->selectObject('section', 'id=' . $section->parent); return self::canView($s); } } }
Base
1
public function get($key, $default = null, $deep = false) { if ($deep) { @trigger_error('Using paths to find deeper items in '.__METHOD__.' is deprecated since version 2.8 and will be removed in 3.0. Filter the returned value in your own code instead.', E_USER_DEPRECATED); } if ($this !== $result = $this->query->get($key, $this, $deep)) { return $result; } if ($this !== $result = $this->attributes->get($key, $this, $deep)) { return $result; } if ($this !== $result = $this->request->get($key, $this, $deep)) { return $result; } return $default; }
Base
1
foreach ($week as $dayNum => $day) { if ($dayNum == $now['mday']) { $currentweek = $weekNum; } if ($dayNum <= $endofmonth) { // $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $db->countObjects("eventdate", $locsql . " AND date >= " . expDateTime::startOfDayTimestamp($day['ts']) . " AND date <= " . expDateTime::endOfDayTimestamp($day['ts'])) : -1; $monthly[$weekNum][$dayNum]['number'] = ($monthly[$weekNum][$dayNum]['ts'] != -1) ? $ed->find("count", $locsql . " AND date >= " . expDateTime::startOfDayTimestamp($day['ts']) . " AND date <= " . expDateTime::endOfDayTimestamp($day['ts'])) : -1; } }
Base
1
function manage_upcharge() { $this->loc->src = "@globalstoresettings"; $config = new expConfig($this->loc); $this->config = $config->config; $gc = new geoCountry(); $countries = $gc->find('all'); $gr = new geoRegion(); $regions = $gr->find('all',null,'rank asc,name asc'); assign_to_template(array( 'countries'=>$countries, 'regions'=>$regions, 'upcharge'=>!empty($this->config['upcharge'])?$this->config['upcharge']:'' )); }
Base
1
static function isSearchable() { return true; }
Base
1
function execute( $par ) { $this->setHeaders(); $this->outputHeader(); $pager = new GlobalNewFilesPager(); $this->getOutput()->addParserOutputContent( $pager->getFullOutput() ); }
Class
2
function getTextColumns($table) { $sql = "SHOW COLUMNS FROM " . $this->prefix.$table . " WHERE type = 'text' OR type like 'varchar%'"; $res = @mysqli_query($this->connection, $sql); if ($res == null) return array(); $records = array(); while($row = mysqli_fetch_object($res)) { $records[] = $row->Field; } return $records; }
Class
2
function db_case($array) { global $DatabaseType; $counter = 0; if ($DatabaseType == 'mysqli') { $array_count = count($array); $string = " CASE WHEN $array[0] ="; $counter++; $arr_count = count($array); for ($i = 1; $i < $arr_count; $i++) { $value = $array[$i]; if ($value == "''" && substr($string, -1) == '=') { $value = ' IS NULL'; $string = substr($string, 0, -1); } $string .= "$value"; if ($counter == ($array_count - 2) && $array_count % 2 == 0) $string .= " ELSE "; elseif ($counter == ($array_count - 1)) $string .= " END "; elseif ($counter % 2 == 0) $string .= " WHEN $array[0]="; elseif ($counter % 2 == 1) $string .= " THEN "; $counter++; } } return $string; }
Base
1
public function __construct() { }
Base
1
form_selectable_cell('<a class="linkEditMain" href="' . html_escape('automation_networks.php?action=edit&id=' . $network['id']) . '">' . $network['name'] . '</a>', $network['id']); form_selectable_cell($network['data_collector'], $network['id']); form_selectable_cell($sched_types[$network['sched_type']], $network['id']); form_selectable_cell(number_format_i18n($network['total_ips']), $network['id'], '', 'text-align:right;'); form_selectable_cell($mystat, $network['id'], '', 'text-align:right;'); form_selectable_cell($progress, $network['id'], '', 'text-align:right;'); form_selectable_cell(number_format_i18n($updown['up']) . '/' . number_format_i18n($updown['snmp']), $network['id'], '', 'text-align:right;'); form_selectable_cell(number_format_i18n($network['threads']), $network['id'], '', 'text-align:right;'); form_selectable_cell(round($network['last_runtime'],2), $network['id'], '', 'text-align:right;'); form_selectable_cell($network['enabled'] == '' || $network['sched_type'] == '1' ? __('N/A'):($network['next_start'] == '0000-00-00 00:00:00' ? substr($network['start_at'],0,16):substr($network['next_start'],0,16)), $network['id'], '', 'text-align:right;'); form_selectable_cell($network['last_started'] == '0000-00-00 00:00:00' ? 'Never':substr($network['last_started'],0,16), $network['id'], '', 'text-align:right;'); form_checkbox_cell($network['name'], $network['id']); form_end_row(); } } else {
Base
1
function db_seq_nextval($seqname) { global $DatabaseType; if ($DatabaseType == 'mysqli') $seq = "fn_" . strtolower($seqname) . "()"; return $seq; }
Base
1
protected function _add_comment_log( $id, $action, $comment = null ) { if ( is_null( $comment ) ) $comment = get_comment( $id ); aal_insert_log( array( 'action' => $action, 'object_type' => 'Comments', 'object_subtype' => get_post_type( $comment->comment_post_ID ), 'object_name' => get_the_title( $comment->comment_post_ID ), 'object_id' => $id, ) ); }
Base
1
public static function hasChildren($i) { global $sections; if (($i + 1) >= count($sections)) return false; return ($sections[$i]->depth < $sections[$i + 1]->depth) ? true : false; }
Base
1
protected function putFileInStorage(UploadedFile $uploadedFile) { $attachmentData = file_get_contents($uploadedFile->getRealPath()); $storage = $this->getStorage(); $basePath = 'uploads/files/' . date('Y-m-M') . '/'; $uploadFileName = Str::random(16) . '.' . $uploadedFile->getClientOriginalExtension(); while ($storage->exists($basePath . $uploadFileName)) { $uploadFileName = Str::random(3) . $uploadFileName; } $attachmentPath = $basePath . $uploadFileName; try { $storage->put($attachmentPath, $attachmentData); } catch (Exception $e) { Log::error('Error when attempting file upload:' . $e->getMessage()); throw new FileUploadException(trans('errors.path_not_writable', ['filePath' => $attachmentPath])); } return $attachmentPath; }
Base
1
$message = getlocal( "Operator {0} joined the chat", array($operator_name), $this->locale, true ); } elseif ($is_operator_back) {
Base
1
(empty($object_uid)? '' : ' AND node_uid = '.protect($object_uid)).' AND website = '.$website->id );
Base
1
function update_option_master() { global $db; $id = empty($this->params['id']) ? null : $this->params['id']; $opt = new option_master($id); $oldtitle = $opt->title; $opt->update($this->params); // if the title of the master changed we should update the option groups that are already using it. if ($oldtitle != $opt->title) { }$db->sql('UPDATE '.$db->prefix.'option SET title="'.$opt->title.'" WHERE option_master_id='.$opt->id); expHistory::back(); }
Class
2
public static function getFolder() { $uri = explode('/', Site::$url); if(count($uri) > 3) { unset($uri[0]); unset($uri[1]); unset($uri[2]); $uri = array_values($uri); $uris = ""; for($i=0; $i<count($uri); $i++){ $uris .= "/".$uri[$i]; } return $uris; }else{ return "/"; } }
Base
1
$fileName = ltrim(dirname($fileName) . '/' . basename($fileName, '.js'), '/.'); if (empty($fileName)) { continue; } $templateNames[] = $inflector->filter(array( 'module' => $moduleName, 'controller' => $controllerName, 'file' => $fileName) ); }
Class
2
protected function _normpath($path) { if (empty($path)) { return '.'; } $changeSep = (DIRECTORY_SEPARATOR !== '/'); if ($changeSep) { $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); } if (strpos($path, '/') === 0) { $initial_slashes = true; } else { $initial_slashes = false; } if (($initial_slashes) && (strpos($path, '//') === 0) && (strpos($path, '///') === false)) { $initial_slashes = 2; } $initial_slashes = (int) $initial_slashes; $comps = explode('/', $path); $new_comps = array(); foreach ($comps as $comp) { if (in_array($comp, array('', '.'))) { continue; } if (($comp != '..') || (!$initial_slashes && !$new_comps) || ($new_comps && (end($new_comps) == '..'))) { array_push($new_comps, $comp); } elseif ($new_comps) { array_pop($new_comps); } } $comps = $new_comps; $path = implode('/', $comps); if ($initial_slashes) { $path = str_repeat('/', $initial_slashes) . $path; } if ($changeSep) { $path = str_replace('/', DIRECTORY_SEPARATOR, $path); } return $path ? $path : '.'; }
Base
1
function select_atversion(){ global $sort_versions; $menu = '<form action="'.$_SERVER['PHP_SELF'].'" method="post">'; $menu.= '<select name="atversions">'; $menu.= '<option value="0">'._AT("all").'</option>'; foreach($sort_versions as $version){ if($version == VERSION){ $menu .= '<option value="'.$version.'" selected="selected">'.$version.'</option>'; }else{ $menu .= '<option value="'.$version.'" >'.$version.'</option>'; } } $menu .='</select>'; $menu .='<input type="submit" value="'. _AT('filter').'"/></form>'; return $menu; }
Compound
4
public function Turn() { $this->error = array("error" => "This method, TURN, of the SMTP ". "is not implemented"); if($this->do_debug >= 1) { $this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'); } return false; }
Class
2
function get_filedisplay_views() { expTemplate::get_filedisplay_views(); $paths = array( BASE.'framework/modules/common/views/file/', BASE.'themes/'.DISPLAY_THEME.'modules/common/views/file/', ); $views = array(); foreach ($paths as $path) { if (is_readable($path)) { $dh = opendir($path); while (($file = readdir($dh)) !== false) { if (is_readable($path.'/'.$file) && substr($file, -4) == '.tpl' && substr($file, -14) != '.bootstrap.tpl' && substr($file, -15) != '.bootstrap3.tpl' && substr($file, -10) != '.newui.tpl') { $filename = substr($file, 0, -4); $views[$filename] = gt($filename); } } } } return $views; }
Class
2
public function __construct(){ }
Base
1
public static function upload_user_avatar() { $file = $_FILES['lp-upload-avatar']; $upload_dir = learn_press_user_profile_picture_upload_dir(); add_filter( 'upload_dir', array( __CLASS__, '_user_avatar_upload_dir' ), 10000 ); $result = wp_handle_upload( $file, array( 'test_form' => false, ) ); remove_filter( 'upload_dir', array( __CLASS__, '_user_avatar_upload_dir' ), 10000 ); if ( is_array( $result ) ) { $result['name'] = $upload_dir['subdir'] . '/' . basename( $result['file'] ); unset( $result['file'] ); } else { $result = array( 'error' => __( 'Profile picture upload failed', 'learnpress' ), ); } learn_press_send_json( $result ); }
Class
2
public function update_discount() { $id = empty($this->params['id']) ? null : $this->params['id']; $discount = new discounts($id); // find required shipping method if needed if ($this->params['required_shipping_calculator_id'] > 0) { $this->params['required_shipping_method'] = $this->params['required_shipping_methods'][$this->params['required_shipping_calculator_id']]; } else { $this->params['required_shipping_calculator_id'] = 0; } $discount->update($this->params); expHistory::back(); }
Class
2
public function getQuerySelect() { return "a.per_tracker_artifact_id AS `" . $this->name . "`"; }
Base
1
private function isWindows() { return DIRECTORY_SEPARATOR !== '/'; }
Class
2
foreach ($data['alertDanger'] as $alert) { # code... echo "<li>$alert</li>\n"; }
Base
1
public function newpassword() { if ($token = $this->param('token')) { $user = $this->app->storage->findOne('cockpit/accounts', ['_reset_token' => $token]); if (!$user) { return false; } $user['md5email'] = md5($user['email']); return $this->render('cockpit:views/layouts/newpassword.php', compact('user', 'token')); } return false; }
Base
1
public function withCookieHeader(RequestInterface $request) { $values = []; $uri = $request->getUri(); $scheme = $uri->getScheme(); $host = $uri->getHost(); $path = $uri->getPath() ?: '/'; foreach ($this->cookies as $cookie) { if ($cookie->matchesPath($path) && $cookie->matchesDomain($host) && !$cookie->isExpired() && (!$cookie->getSecure() || $scheme == 'https') ) { $values[] = $cookie->getName() . '=' . self::getCookieValue($cookie->getValue()); } } return $values ? $request->withHeader('Cookie', implode('; ', $values)) : $request; }
Base
1
function get_filedisplay_views() { expTemplate::get_filedisplay_views(); $paths = array( BASE.'framework/modules/common/views/file/', BASE.'themes/'.DISPLAY_THEME.'modules/common/views/file/', ); $views = array(); foreach ($paths as $path) { if (is_readable($path)) { $dh = opendir($path); while (($file = readdir($dh)) !== false) { if (is_readable($path.'/'.$file) && substr($file, -4) == '.tpl' && substr($file, -14) != '.bootstrap.tpl' && substr($file, -15) != '.bootstrap3.tpl' && substr($file, -10) != '.newui.tpl') { $filename = substr($file, 0, -4); $views[$filename] = gt($filename); } } } } return $views; }
Class
2
protected function _fopen($path, $mode='rb') { // try ftp stream wrapper if ($this->options['mode'] == 'passive' && ini_get('allow_url_fopen')) { $url = 'ftp://'.$this->options['user'].':'.$this->options['pass'].'@'.$this->options['host'].':'.$this->options['port'].$path; if (strtolower($mode[0]) === 'w') { $context = stream_context_create(array('ftp' => array('overwrite' => true))); $fp = @fopen($url, $mode, false, $context); } else { $fp = @fopen($url, $mode); } if ($fp) { return $fp; } } if ($this->tmp) { $local = $this->getTempFile($path); $fp = @fopen($local, 'wb'); if (ftp_fget($this->connect, $fp, $path, FTP_BINARY)) { fclose($fp); $fp = fopen($local, $mode); return $fp; } @fclose($fp); is_file($local) && @unlink($local); } return false; }
Base
1
public function Load($tree) { if (!$tree) return; $contents = array(); $treePath = $tree->GetPath(); $args = array(); $args[] = '--full-name'; if ($this->exe->CanShowSizeInTree()) $args[] = '-l'; $args[] = '-t'; $args[] = $tree->GetHash(); $lines = explode("\n", $this->exe->Execute($tree->GetProject()->GetPath(), GIT_LS_TREE, $args)); foreach ($lines as $line) { if (preg_match("/^([0-9]+) (.+) ([0-9a-fA-F]{40})(\s+[0-9]+|\s+-)?\t(.+)$/", $line, $regs)) { switch($regs[2]) { case 'tree': $data = array(); $data['type'] = 'tree'; $data['hash'] = $regs[3]; $data['mode'] = $regs[1]; $path = $regs[5]; if (!empty($treePath)) $path = $treePath . '/' . $path; $data['path'] = $path; $contents[] = $data; break; case 'blob': $data = array(); $data['type'] = 'blob'; $data['hash'] = $regs[3]; $data['mode'] = $regs[1]; $path = $regs[5]; if (!empty($treePath)) $path = $treePath . '/' . $path; $data['path'] = $path; $size = trim($regs[4]); if (!empty($size)) $data['size'] = $size; $contents[] = $data; break; } } } return $contents; }
Base
1
private function _modifiedby( $option ) { $this->addTable( 'revision_actor_temp', 'change_rev' ); $user = new \User; $this->addWhere( $this->DB->addQuotes( $user->newFromName( $option )->getActorId() ) . ' = change_rev.revactor_actor AND change_rev.revactor_page = page_id' ); }
Class
2
public function resetKey(){ $login_user = $this->checkLogin(); $item_id = I("item_id/d"); $item = D("Item")->where("item_id = '$item_id' ")->find(); if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){ $this->sendError(10303); return ; } $ret = D("ItemToken")->where("item_id = '$item_id' ")->delete(); if ($ret) { $this->getKey(); }else{ $this->sendError(10101); } }
Compound
4
public function testDeleteCommentAction() { $client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN); $this->assertAccessIsGranted($client, '/admin/project/1/details'); $form = $client->getCrawler()->filter('form[name=project_comment_form]')->form(); $client->submit($form, [ 'project_comment_form' => [ 'message' => 'Foo bar blub', ] ]); $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details')); $client->followRedirect(); $node = $client->getCrawler()->filter('div.box#comments_box .direct-chat-text'); self::assertStringContainsString('Foo bar blub', $node->html()); $node = $client->getCrawler()->filter('div.box#comments_box .box-body a.confirmation-link'); $comments = $this->getEntityManager()->getRepository(ProjectComment::class)->findAll(); $id = $comments[0]->getId(); self::assertEquals($this->createUrl('/admin/project/' . $id . '/comment_delete'), $node->attr('href')); $this->request($client, '/admin/project/' . $id . '/comment_delete'); $this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details')); $client->followRedirect(); $node = $client->getCrawler()->filter('div.box#comments_box .box-body'); self::assertStringContainsString('There were no comments posted yet', $node->html()); }
Compound
4
function db_start() { global $DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort, $DatabaseType; switch ($DatabaseType) { case 'mysqli': $connection = new mysqli($DatabaseServer, $DatabaseUsername, $DatabasePassword, $DatabaseName, $DatabasePort); break; } // Error code for both. if ($connection === false) { switch ($DatabaseType) { case 'mysqli': $errormessage = mysqli_error($connection); break; } db_show_error("", "" . _couldNotConnectToDatabase . ": $DatabaseServer", $errormessage); } return $connection; }
Base
1
public function gc($force = false, $expiredOnly = true) { if ($force || mt_rand(0, 1000000) < $this->gcProbability) { $this->gcRecursive($this->cachePath, $expiredOnly); } }
Class
2
public function get($extramediatypes = false) { try { return $this->getConfig($extramediatypes); } catch (\Exception $exception) { return $this->jsonError($exception); } }
Base
1
public function checkLdapLogin($username ,$password ){ $ldap_open = D("Options")->get("ldap_open" ) ; $ldap_form = D("Options")->get("ldap_form" ) ; $ldap_form = json_decode($ldap_form,1); if (!$ldap_open) { return false; } if (!$ldap_form['user_field']) { $ldap_form['user_field'] = 'cn'; } $ldap_conn = ldap_connect($ldap_form['host'], $ldap_form['port']);//建立与 LDAP 服务器的连接 if (!$ldap_conn) { return false; } ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, $ldap_form['version']); $rs=ldap_bind($ldap_conn, $ldap_form['bind_dn'], $ldap_form['bind_password']);//与服务器绑定 用户登录验证 成功返回1 if (!$rs) { return false ; } $result = ldap_search($ldap_conn,$ldap_form['base_dn'],"(cn=*)"); $data = ldap_get_entries($ldap_conn, $result); for ($i=0; $i<$data["count"]; $i++) { $ldap_user = $data[$i][$ldap_form['user_field']][0] ; $dn = $data[$i]["dn"] ; if ($ldap_user == $username) { //如果该用户不在数据库里,则帮助其注册 $userInfo = D("User")->isExist($username) ; if(!$userInfo){ D("User")->register($ldap_user,$ldap_user.time()); } $rs2=ldap_bind($ldap_conn, $dn , $password); if ($rs2) { D("User")->updatePwd($userInfo['uid'], $password); return $this->checkLogin($username,$password); } } } return false ; }
Base
1
public function testEncodeFormulasWithSettingsPassedInContext() { $this->assertSame(<<<'CSV' 0 " =2+3" CSV , $this->encoder->encode(['=2+3'], 'csv', [ CsvEncoder::ESCAPE_FORMULAS_KEY => true, ])); $this->assertSame(<<<'CSV' 0 " -2+3" CSV , $this->encoder->encode(['-2+3'], 'csv', [ CsvEncoder::ESCAPE_FORMULAS_KEY => true, ])); $this->assertSame(<<<'CSV' 0 " +2+3" CSV , $this->encoder->encode(['+2+3'], 'csv', [ CsvEncoder::ESCAPE_FORMULAS_KEY => true, ])); $this->assertSame(<<<'CSV' 0 " @MyDataColumn" CSV , $this->encoder->encode(['@MyDataColumn'], 'csv', [ CsvEncoder::ESCAPE_FORMULAS_KEY => true, ])); }
Base
1
public function updateFile(Attachment $attachment, $requestData) { $attachment->name = $requestData['name']; if (isset($requestData['link']) && trim($requestData['link']) !== '') { $attachment->path = $requestData['link']; if (!$attachment->external) { $this->deleteFileInStorage($attachment); $attachment->external = true; } } $attachment->save(); return $attachment; }
Base
1
private function load($id) { try { $select = $this->zdb->select(self::TABLE); $select->limit(1)->where(self::PK . ' = ' . $id); $results = $this->zdb->execute($select); $res = $results->current(); $this->id = $id; $this->name = $res->type_name; } catch (Throwable $e) { Analog::log( 'An error occurred loading payment type #' . $id . "Message:\n" . $e->getMessage(), Analog::ERROR ); throw $e; } }
Base
1
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
public function getQueryGroupby() { //Last update date is stored in the changeset (the date of the changeset) return 'c.submitted_on'; }
Base
1
public function load_by_profile($network, $network_user_id) { global $DB; global $session; // the profile exists (connected to a social network)? $swuser = $DB->query_single( 'webuser', 'nv_webuser_profiles', ' network = '.protect($network).' AND '. ' network_user_id = '.protect($network_user_id) ); if(!empty($swuser)) $this->load($swuser); }
Base
1
function send_reset_confirmation_request($name) { global $sitename; $rs = safe_row("email, nonce", 'txp_users', "name = '".doSlash($name)."'"); if ($rs) { extract($rs); $confirm = bin2hex(pack('H*', substr(md5($nonce), 0, 10)).$name); $message = gTxt('greeting').' '.$name.','. n.n.gTxt('password_reset_confirmation').': '. n.hu.'textpattern/index.php?confirm='.$confirm; if (txpMail($email, "[$sitename] ".gTxt('password_reset_confirmation_request'), $message)) { return gTxt('password_reset_confirmation_request_sent'); } else { return array(gTxt('could_not_mail'), E_ERROR); } } else { // Though 'unknown_author' could be thrown, send generic 'request_sent' // message instead so that (non-)existence of account names are not leaked. return gTxt('password_reset_confirmation_request_sent'); } }
Base
1
private function _qualitypages( $option ) { if ( function_exists( 'efLoadFlaggedRevs' ) ) { //Do not add this again if 'stablepages' has already added it. if ( !$this->parametersProcessed['stablepages'] ) { $this->addJoin( 'flaggedpages', [ "LEFT JOIN", "page_id = fp_page_id" ] ); } switch ( $option ) { case 'only': $this->addWhere( 'fp_quality >= 1' ); break; case 'exclude': $this->addWhere( 'fp_quality = 0' ); break; } } }
Class
2
public function Hello($host = '') { $this->error = null; // so no confusion is caused if(!$this->connected()) { $this->error = array( "error" => "Called Hello() without being connected"); return false; } // if hostname for HELO was not specified send default if(empty($host)) { // determine appropriate default to send to server $host = "localhost"; } // Send extended hello first (RFC 2821) if(!$this->SendHello("EHLO", $host)) { if(!$this->SendHello("HELO", $host)) { return false; } } return true; }
Class
2
$user = db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($check['user']), 'username'); form_alternate_row('line' . $check['id']); $name = get_data_source_title($check['datasource']); $title = $name; if (strlen($name) > 50) { $name = substr($name, 0, 50); } form_selectable_cell('<a class="linkEditMain" title="' . $title .'" href="' . htmlspecialchars('data_debug.php?action=view&id=' . $check['id']) . '">' . $name . '</a>', $check['id']); form_selectable_cell($user, $check['id']); form_selectable_cell(date('F j, Y, G:i', $check['started']), $check['id']); form_selectable_cell($check['datasource'], $check['id']); form_selectable_cell(debug_icon(($check['done'] ? (strlen($issue_line) ? 'off' : 'on' ) : '')), $check['id'], '', 'text-align: center;'); form_selectable_cell(debug_icon($info['rrd_writable']), $check['id'], '', 'text-align: center;'); form_selectable_cell(debug_icon($info['rrd_exists']), $check['id'], '', 'text-align: center;'); form_selectable_cell(debug_icon($info['active']), $check['id'], '', 'text-align: center;'); form_selectable_cell(debug_icon($info['rrd_match']), $check['id'], '', 'text-align: center;'); form_selectable_cell(debug_icon($info['valid_data']), $check['id'], '', 'text-align: center;'); form_selectable_cell(debug_icon(($info['rra_timestamp2'] != '' ? 1 : '')), $check['id'], '', 'text-align: center;'); form_selectable_cell('<a class=\'linkEditMain\' href=\'#\' title="' . html_escape($issue_title) . '">' . html_escape(strlen(trim($issue_line)) ? $issue_line : '<none>') . '</a>', $check['id']); form_checkbox_cell($check['id'], $check['id']); form_end_row(); } }else{
Base
1
public function chmod() { if (!AuthUser::hasPermission('file_manager_chmod')) { Flash::set('error', __('You do not have sufficient permissions to change the permissions on a file or directory.')); redirect(get_url('plugin/file_manager/browse/')); } // CSRF checks if (isset($_POST['csrf_token'])) { $csrf_token = $_POST['csrf_token']; if (!SecureToken::validateToken($csrf_token, BASE_URL.'plugin/file_manager/chmod')) { Flash::set('error', __('Invalid CSRF token found!')); redirect(get_url('plugin/file_manager/browse/')); } } else { Flash::set('error', __('No CSRF token found!')); redirect(get_url('plugin/file_manager/browse/')); } $data = $_POST['file']; $data['name'] = str_replace('..', '', $data['name']); $file = FILES_DIR . '/' . $data['name']; if (file_exists($file)) { if (@!chmod($file, octdec($data['mode']))) Flash::set('error', __('Permission denied!')); } else { Flash::set('error', __('File or directory not found!')); } $path = substr($data['name'], 0, strrpos($data['name'], '/')); redirect(get_url('plugin/file_manager/browse/' . $path)); }
Class
2
public function limit($value) { if ($value >= 0) { $this->limit = $value; } return $this; }
Base
1
public static function getHost() { if (isset($_SERVER['HTTP_HOST'])) { $site_address = (erLhcoreClassSystem::$httpsMode == true ? 'https:' : 'http:') . '//' . $_SERVER['HTTP_HOST'] ; } else if (class_exists('erLhcoreClassInstance')) { $site_address = 'https://' . erLhcoreClassInstance::$instanceChat->address . '.' . erConfigClassLhConfig::getInstance()->getSetting( 'site', 'seller_domain'); } else if (class_exists('erLhcoreClassExtensionLhcphpresque')) { $site_address = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionLhcphpresque')->settings['site_address']; } else { $site_address = ''; } return $site_address; }
Class
2
public static function page($vars) { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/".self::slug($vars).GX_URL_PREFIX; break; default: # code... $url = Options::get('siteurl')."/index.php?page={$vars}"; break; } return $url; }
Base
1
public function __construct( Parameters $parameters ) { $this->parameters = $parameters; $this->tableNames = self::getTableNames(); $this->DB = wfGetDB( DB_REPLICA, 'dpl' ); }
Class
2
public function whereFileName($fileName) { $this->selectSingle = $this->model->getFileNameParts($fileName); return $this; }
Base
1
public function confirm() { $project = $this->getProject(); $this->response->html($this->helper->layout->project('column/remove', array( 'column' => $this->columnModel->getById($this->request->getIntegerParam('column_id')), 'project' => $project, ))); }
Base
1
public function display_sdm_other_details_meta_box($post) { //Other details metabox $file_size = get_post_meta($post->ID, 'sdm_item_file_size', true); $file_size = isset($file_size) ? $file_size : ''; $version = get_post_meta($post->ID, 'sdm_item_version', true); $version = isset($version) ? $version : ''; echo '<div class="sdm-download-edit-filesize">'; _e('File Size: ', 'simple-download-monitor'); echo '<br />'; echo ' <input type="text" name="sdm_item_file_size" value="' . $file_size . '" size="20" />'; echo '<p class="description">' . __('Enter the size of this file (example value: 2.15 MB). You can show this value in the fancy display by using a shortcode parameter.', 'simple-download-monitor') . '</p>'; echo '</div>'; echo '<div class="sdm-download-edit-version">'; _e('Version: ', 'simple-download-monitor'); echo '<br />'; echo ' <input type="text" name="sdm_item_version" value="' . $version . '" size="20" />'; echo '<p class="description">' . __('Enter the version number for this item if any (example value: v2.5.10). You can show this value in the fancy display by using a shortcode parameter.', 'simple-download-monitor') . '</p>'; echo '</div>'; wp_nonce_field('sdm_other_details_nonce', 'sdm_other_details_nonce_check'); }
Base
1
}elseif ($k == 'lang') { self::incFront('default'); }elseif($k == "error"){
Base
1
foreach ($evs as $key=>$event) { if ($condense) { $eventid = $event->id; $multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;')); if (!empty($multiday_event)) { unset($evs[$key]); continue; } } $evs[$key]->eventstart += $edate->date; $evs[$key]->eventend += $edate->date; $evs[$key]->date_id = $edate->id; if (!empty($event->expCat)) { $catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color); // if (substr($catcolor,0,1)=='#') $catcolor = '" style="color:'.$catcolor.';'; $evs[$key]->color = $catcolor; } }
Base
1
public function getHeaders() { return $this->headerLines; }
Base
1
public function show($image_name) { $imageFile = storage_path('app/'.str_replace("-","/",$image_name)); if(!is_file($imageFile)){ abort(404); } $image = Image::make($imageFile); if(config('tipask.upload.open_watermark') && $image_name != config('tipask.upload.watermark_image') && str_contains($image_name,'attachments')){ $watermarkImage = storage_path('app/'.str_replace("-","/",config('tipask.upload.watermark_image'))); $image->insert($watermarkImage, 'bottom-right', 15, 10); } $response = response()->make($image->encode('jpg')); $response->header('Content-Type', 'image/jpeg'); $response->header('Expires', date(DATE_RFC822,strtotime(" 7 day"))); $response->header('Cache-Control', 'private, max-age=259200, pre-check=259200'); return $response; }
Base
1
public function testXssExternalLinkImg() { $antiXss = new \MicroweberPackages\Helper\HTMLClean(); $string = '<img src="'.site_url().'test.jpg" />'; $content = $antiXss->clean($string); $this->assertEquals('<img src="'.site_url().'test.jpg" alt="test.jpg" />', $content); $string = '<img src="https://google.bg/test.jpg" />'; $content = $antiXss->clean($string); $this->assertEquals('', $content); }
Base
1
public function getAlnum($key, $default = '', $deep = false) { return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep)); }
Base
1
foreach ($allusers as $uid) { $u = user::getUserById($uid); expPermissions::grant($u, 'manage', $sloc); }
Class
2
private function edebug($str) { if ($this->Debugoutput == "error_log") { error_log($str); } else { echo $str; } }
Class
2
function import() { $pullable_modules = expModules::listInstalledControllers($this->baseclassname); $modules = new expPaginator(array( 'records' => $pullable_modules, 'controller' => $this->loc->mod, 'action' => $this->params['action'], 'order' => isset($this->params['order']) ? $this->params['order'] : 'section', 'dir' => isset($this->params['dir']) ? $this->params['dir'] : '', 'page' => (isset($this->params['page']) ? $this->params['page'] : 1), 'columns' => array( gt('Title') => 'title', gt('Page') => 'section' ), )); assign_to_template(array( 'modules' => $modules, )); }
Base
1
function setParameter($a_name, $a_value) { $this->parameters[$a_name] = $a_value; }
Base
1
public function confirm() { $project = $this->getProject(); $this->response->html($this->helper->layout->project('action/remove', array( 'action' => $this->actionModel->getById($this->request->getIntegerParam('action_id')), 'available_events' => $this->eventManager->getAll(), 'available_actions' => $this->actionManager->getAvailableActions(), 'project' => $project, 'title' => t('Remove an action') ))); }
Base
1
private function addServiceInstance($id, Definition $definition, $isSimpleInstance) { $class = $this->dumpValue($definition->getClass()); if (0 === strpos($class, "'") && false === strpos($class, '$') && !preg_match('/^\'(?:\\\{2})?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); } $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition); $instantiation = ''; if (!$isProxyCandidate && $definition->isShared()) { $instantiation = "\$this->services['$id'] = ".($isSimpleInstance ? '' : '$instance'); } elseif (!$isSimpleInstance) {
Base
1
public function testClientIpIsAlwaysLocalhostForForwardedRequests() { $this->setNextResponse(); $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); }
Class
2
public function load_template() { global $DB; global $website; $template = new template(); if( $this->association == 'free' || ($this->association == 'category' && $this->embedding == '0')) { $template->load($this->template); } else { $category_template = $DB->query_single( 'template', 'nv_structure', ' id = '.protect($this->category).' AND website = '.$website->id ); $template->load($category_template); } return $template; }
Base
1
public function confirm() { $task = $this->getTask(); $subtask = $this->getSubtask(); $this->response->html($this->template->render('subtask/remove', array( 'subtask' => $subtask, 'task' => $task, ))); }
Base
1
$contents = ['form' => tep_draw_form('zones', 'zones.php', 'page=' . $_GET['page'] . '&action=insert')];
Base
1
public function deleteCommentAction(ProjectComment $comment) { $projectId = $comment->getProject()->getId(); try { $this->repository->deleteComment($comment); } catch (\Exception $ex) { $this->flashDeleteException($ex); } return $this->redirectToRoute('project_details', ['id' => $projectId]); }
Compound
4
public function getSection() { global $db; if (expTheme::inAction()) { if (isset($_REQUEST['section'])) { $section = $this->url_style=="sef" ? $this->getPageByName($_REQUEST['section'])->id : intval($_REQUEST['section']) ; } else { $section = (expSession::is_set('last_section') ? expSession::get('last_section') : SITE_DEFAULT_SECTION); } } else { $section = (isset($_REQUEST['section']) ? intval($_REQUEST['section']) : SITE_DEFAULT_SECTION); } $testsection = $db->selectObject('section','id='.$section); if (empty($testsection)) { $section = SITE_DEFAULT_SECTION; } return $section; }
Base
1
public static function generated(){ $end_time = microtime(TRUE); $time_taken = $end_time - $GLOBALS['start_time']; $time_taken = round($time_taken,5); echo '<center><small>Page generated in '.$time_taken.' seconds.</small></center>'; }
Base
1
public function setSectionSeparators( ?array $separators ) { $this->sectionSeparators = (array)$separators ?? []; }
Class
2
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
$percent = round($percent, 0); } else { $percent = round($percent, 2); // school default } if ($ret == '%') return $percent; if (!$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id]) $_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] = DBGet(DBQuery('SELECT TITLE,ID,BREAK_OFF FROM report_card_grades WHERE SYEAR=\'' . $cp[1]['SYEAR'] . '\' AND SCHOOL_ID=\'' . $cp[1]['SCHOOL_ID'] . '\' AND GRADE_SCALE_ID=\'' . $grade_scale_id . '\' ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER')); foreach ($_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] as $grade) { if ($does_breakoff == 'Y' ? $percent >= $programconfig[$staff_id][$course_period_id . '-' . $grade['ID']] && is_numeric($programconfig[$staff_id][$course_period_id . '-' . $grade['ID']]) : $percent >= $grade['BREAK_OFF']) return $ret == 'ID' ? $grade['ID'] : $grade['TITLE']; } }
Base
1
public function getCast($id){ $url = "http://api.themoviedb.org/3/movie/{$id}/credits?api_key=".$this->apikey; $cast = $this->curl($url); return $cast; }
Base
1
public function addJoin( $tableAlias, $joinConditions ) { if ( empty( $tableAlias ) || empty( $joinConditions ) ) { throw new \MWException( __METHOD__ . ': An empty join clause was passed.' ); } if ( isset( $this->join[$tableAlias] ) ) { throw new \MWException( __METHOD__ . ': Attempted to overwrite existing join clause.' ); } $this->join[$tableAlias] = $joinConditions; return true; }
Class
2