code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
function addDiscountToCart() { // global $user, $order; global $order; //lookup discount to see if it's real and valid, and not already in our cart //this will change once we allow more than one coupon code $discount = new discounts(); $discount = $discount->getCouponByName($this->params['coupon_code']); if (empty($discount)) { flash('error', gt("This discount code you entered does not exist.")); //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); expHistory::back(); } //check to see if it's in our cart already if ($this->isDiscountInCart($discount->id)) { flash('error', gt("This discount code is already in your cart.")); //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); expHistory::back(); } //this should really be reworked, as it shoudn't redirect directly and not return $validateDiscountMessage = $discount->validateDiscount(); if ($validateDiscountMessage == "") { //if all good, add to cart, otherwise it will have redirected $od = new order_discounts(); $od->orders_id = $order->id; $od->discounts_id = $discount->id; $od->coupon_code = $discount->coupon_code; $od->title = $discount->title; $od->body = $discount->body; $od->save(); // set this to just the discount applied via this coupon?? if so, when though? $od->discount_total = ??; flash('message', gt("The discount code has been applied to your cart.")); } else { flash('error', $validateDiscountMessage); } //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); expHistory::back(); }
Class
2
final public function modifyLimitQuery($query, $limit, $offset = 0) { if ($offset < 0) { throw new Exception(sprintf( 'Offset must be a positive integer or zero, %d given', $offset )); } if ($offset > 0 && ! $this->supportsLimitOffset()) { throw new Exception(sprintf( 'Platform %s does not support offset values in limit queries.', $this->getName() )); } return $this->doModifyLimitQuery($query, $limit, $offset); }
Base
1
public static function content($vars) { $post = Typo::Xclean($vars); preg_match_all("[[\-\-readmore\-\-]]", $post, $more); if (is_array($more[0])) { $post = str_replace('[[--readmore--]]', '', $post); // return $post; }else{ $post = $post; } $post = Hooks::filter('post_content_filter', $post); return $post; }
Base
1
function __construct () { }
Base
1
public function save() { $project = $this->getProject(); $values = $this->request->getValues(); list($valid, $errors) = $this->categoryValidator->validateCreation($values); if ($valid) { if ($this->categoryModel->create($values) !== false) { $this->flash->success(t('Your category have been created successfully.')); $this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])), true); return; } else { $errors = array('name' => array(t('Another category with the same name exists in this project'))); } } $this->create($values, $errors); }
Base
1
$module_views[$key]['name'] = gt($value['name']); } // look for a config form for this module's current view // $controller->loc->mod = expModules::getControllerClassName($controller->loc->mod); //check to see if hcview was passed along, indicating a hard-coded module // if (!empty($controller->params['hcview'])) { // $viewname = $controller->params['hcview']; // } else { // $viewname = $db->selectValue('container', 'view', "internal='".serialize($controller->loc)."'"); // } // $viewconfig = $viewname.'.config'; // foreach ($modpaths as $path) { // if (file_exists($path.'/'.$viewconfig)) { // $fileparts = explode('_', $viewname); // if ($fileparts[0]=='show'||$fileparts[0]=='showall') array_shift($fileparts); // $module_views[$viewname]['name'] = ucwords(implode(' ', $fileparts)).' '.gt('View Configuration'); // $module_views[$viewname]['file'] =$path.'/'.$viewconfig; // } // } // sort the views highest to lowest by filename // we are reverse sorting now so our array merge // will overwrite property..we will run array_reverse // when we're finished to get them back in the right order krsort($common_views); krsort($module_views); if (!empty($moduleconfig)) $common_views = array_merge($common_views, $moduleconfig); $views = array_merge($common_views, $module_views); $views = array_reverse($views); return $views; }
Base
1
protected function _chmod($path, $mode) { $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); $ret = @chmod($path, $modeOct); $ret && clearstatcache(); return $ret; }
Base
1
public function testAuthCheckDecryptUser() { $GLOBALS['cfg']['Server']['auth_swekey_config'] = 'testConfigSwekey'; $GLOBALS['server'] = 1; $_REQUEST['old_usr'] = ''; $_REQUEST['pma_username'] = ''; $_COOKIE['pmaServer-1'] = 'pmaServ1'; $_COOKIE['pmaUser-1'] = 'pmaUser1'; $_COOKIE['pma_iv-1'] = base64_encode('testiv09testiv09'); $GLOBALS['cfg']['blowfish_secret'] = 'secret'; $_SESSION['last_access_time'] = ''; $_SESSION['last_valid_captcha'] = true; // mock for blowfish function $this->object = $this->getMockBuilder('AuthenticationCookie') ->disableOriginalConstructor() ->setMethods(array('cookieDecrypt')) ->getMock(); $this->object->expects($this->once()) ->method('cookieDecrypt') ->will($this->returnValue('testBF')); $this->assertFalse( $this->object->authCheck() ); $this->assertEquals( 'testBF', $GLOBALS['PHP_AUTH_USER'] ); }
Class
2
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 updateForgottenPassword(array $input) { $condition = [ 'glpi_users.is_active' => 1, 'glpi_users.is_deleted' => 0, [ 'OR' => [ ['glpi_users.begin_date' => null], ['glpi_users.begin_date' => ['<', new QueryExpression('NOW()')]] ], ], [ 'OR' => [ ['glpi_users.end_date' => null], ['glpi_users.end_date' => ['>', new QueryExpression('NOW()')]] ] ] ]; if ($this->getFromDBbyEmail($input['email'], $condition)) { if (($this->fields["authtype"] == Auth::DB_GLPI) || !Auth::useAuthExt()) { if (($input['password_forget_token'] == $this->fields['password_forget_token']) && (abs(strtotime($_SESSION["glpi_currenttime"]) -strtotime($this->fields['password_forget_token_date'])) < DAY_TIMESTAMP)) { $input['id'] = $this->fields['id']; Config::validatePassword($input["password"], false); // Throws exception if password is invalid if (!$this->update($input)) { return false; } $input2 = [ 'password_forget_token' => '', 'password_forget_token_date' => null, 'id' => $this->fields['id'] ]; $this->update($input2); return true; } else { throw new ForgetPasswordException(__('Your password reset request has expired or is invalid. Please renew it.')); } } else { throw new ForgetPasswordException(__("The authentication method configuration doesn't allow you to change your password.")); } } else { throw new ForgetPasswordException(__('Email address not found.')); } return false; }
Base
1
static function isSearchable() { return true; }
Base
1
$fieldPickListValues[$value] = \App\Language::translate($value, $this->getModuleName(),false,false); } // Protection against deleting a value that does not exist on the list if ('picklist' === $fieldDataType) { $fieldValue = $this->get('fieldvalue'); if (!empty($fieldValue) && !isset($fieldPickListValues[$fieldValue])) { $fieldPickListValues[$fieldValue] = \App\Language::translate($fieldValue, $this->getModuleName(),false,false); $this->set('isEditableReadOnly', true); } } } elseif (method_exists($this->getUITypeModel(), 'getPicklistValues')) {
Class
2
public function offset($offset) { $this->ar_offset = $offset; return $this; }
Base
1
function selectArraysBySql($sql) { $res = @mysqli_query($this->connection, $sql); if ($res == null) return array(); $arrays = array(); for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++) $arrays[] = mysqli_fetch_assoc($res); return $arrays; }
Base
1
$module_views[$key]['name'] = gt($value['name']); } // look for a config form for this module's current view // $controller->loc->mod = expModules::getControllerClassName($controller->loc->mod); //check to see if hcview was passed along, indicating a hard-coded module // if (!empty($controller->params['hcview'])) { // $viewname = $controller->params['hcview']; // } else { // $viewname = $db->selectValue('container', 'view', "internal='".serialize($controller->loc)."'"); // } // $viewconfig = $viewname.'.config'; // foreach ($modpaths as $path) { // if (file_exists($path.'/'.$viewconfig)) { // $fileparts = explode('_', $viewname); // if ($fileparts[0]=='show'||$fileparts[0]=='showall') array_shift($fileparts); // $module_views[$viewname]['name'] = ucwords(implode(' ', $fileparts)).' '.gt('View Configuration'); // $module_views[$viewname]['file'] =$path.'/'.$viewconfig; // } // } // sort the views highest to lowest by filename // we are reverse sorting now so our array merge // will overwrite property..we will run array_reverse // when we're finished to get them back in the right order krsort($common_views); krsort($module_views); if (!empty($moduleconfig)) $common_views = array_merge($common_views, $moduleconfig); $views = array_merge($common_views, $module_views); $views = array_reverse($views); return $views; }
Base
1
public static function sortByPriority( $parameters ) { if ( !is_array( $parameters ) ) { throw new \MWException( __METHOD__ . ': A non-array was passed.' ); } //'category' to get category headings first for ordermethod. //'include'/'includepage' to make sure section labels are ready for 'table'. $priority = [ 'distinct' => 1, 'openreferences' => 2, 'ignorecase' => 3, 'category' => 4, 'title' => 5, 'goal' => 6, 'ordercollation' => 7, 'ordermethod' => 8, 'includepage' => 9, 'include' => 10 ]; $_first = []; foreach ( $priority as $parameter => $order ) { if ( isset( $parameters[$parameter] ) ) { $_first[$parameter] = $parameters[$parameter]; unset( $parameters[$parameter] ); } } $parameters = $_first + $parameters; return $parameters; }
Class
2
protected function _add_log_attachment( $action, $attachment_id ) { $post = get_post( $attachment_id ); aal_insert_log( array( 'action' => $action, 'object_type' => 'Attachment', 'object_subtype' => $post->post_type, 'object_id' => $attachment_id, 'object_name' => get_the_title( $post->ID ), ) ); }
Base
1
public function __construct($exceptions = false) { $this->exceptions = ($exceptions == true); }
Compound
4
public function edit(Request $request, $id) { return $this->view('content::admin.content.edit', [ 'content_id'=>$id ]); }
Base
1
public function settings_save() { 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()); } if (!isset($_POST['settings'])) { Flash::set('error', 'File Manager - ' . __('form was not posted.')); redirect(get_url('plugin/file_manager/settings')); } else { $settings = $_POST['settings']; if ($settings['umask'] == 0) $settings['umask'] = 0; elseif (!preg_match('/^0?[0-7]{3}$/', $settings['umask'])) $settings['umask'] = 0; if (strlen($settings['umask']) === 3) $settings['umask'] = '0' . $settings['umask']; elseif (strlen($settings['umask']) !== 4 && $settings['umask'] != 0) $settings['umask'] = 0; if (!preg_match('/^0?[0-7]{3}$/', $settings['dirmode'])) $settings['dirmode'] = '0755'; if (strlen($settings['dirmode']) === 3) $settings['dirmode'] = '0' . $settings['dirmode']; if (!preg_match('/^0?[0-7]{3}$/', $settings['filemode'])) $settings['filemode'] = '0755'; if (strlen($settings['filemode']) === 3) $settings['filemode'] = '0' . $settings['filemode']; } if (Plugin::setAllSettings($settings, 'file_manager')) Flash::setNow('success', 'File Manager - ' . __('plugin settings saved.')); else Flash::setNow('error', 'File Manager - ' . __('plugin settings not saved!')); $this->display('file_manager/views/settings', array('settings' => $settings)); }
Class
2
public function getHeader($header) { $name = strtolower($header); return isset($this->headers[$name]) ? $this->headers[$name] : []; }
Base
1
public function remove($key) { $session =& $this->getSessionRef($key); unset($session); return $this; }
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, ))); }
Base
1
function PMA_secureSession() { // prevent session fixation and XSS // (better to use session_status() if available) if ((PMA_PHP_INT_VERSION >= 50400 && session_status() === PHP_SESSION_ACTIVE) || (PMA_PHP_INT_VERSION < 50400 && session_id() !== '') ) { session_regenerate_id(true); } $_SESSION[' PMA_token '] = md5(uniqid(rand(), true)); }
Class
2
foreach ($all_users as &$u) { if ($u['username'] == $username && $this->verifyPassword($password, $u['password'])) { $user = $this->mapToUserObject($u); $this->store($user); $this->session->set(self::SESSION_HASH, $u['password']); return true; } }
Compound
4
public static function DragnDropReRank2() { global $router, $db; $id = $router->params['id']; $page = new section($id); $old_rank = $page->rank; $old_parent = $page->parent; $new_rank = $router->params['position'] + 1; // rank $new_parent = intval($router->params['parent']); $db->decrement($page->tablename, 'rank', 1, 'rank>' . $old_rank . ' AND parent=' . $old_parent); // close in hole $db->increment($page->tablename, 'rank', 1, 'rank>=' . $new_rank . ' AND parent=' . $new_parent); // make room $params = array(); $params['parent'] = $new_parent; $params['rank'] = $new_rank; $page->update($params); self::checkForSectionalAdmins($id); expSession::clearAllUsersSessionCache('navigation'); }
Base
1
function setup() { $this -> catch_globals(); $this -> version['prior'] = '01'; $this -> version['minor'] = '06'; $this -> version['fix'] = '01'; $this -> version_text = $this -> version['prior']; $this -> version_text .= '.'; $this -> version_text .= $this -> version['minor']; $this -> version_text .= '.'; $this -> version_text .= $this -> version['fix']; //manipulate some actions if user chose updat if ($this -> globals['mode'] == 'update') { //seperate update finish screen if ($this -> globals['action'] == 'enter_email') $this -> globals['action'] = 'screen_execute_update_and_finish'; } }
Base
1
public function __construct( AuthManager $auth, Repository $config, CacheRepository $cache, UserRepositoryInterface $repository, ViewFactory $view ) { parent::__construct($auth, $config); $this->view = $view; $this->cache = $cache; $this->repository = $repository; }
Class
2
self::removeLevel($kid->id); } }
Base
1
public static function load_object_strings($node_type, $node_id, $node_uid=null) { global $DB; $DB->query(' SELECT subtype, lang, text FROM nv_webdictionary WHERE node_type = '.protect($node_type).' AND node_id = '.protect($node_id). (empty($node_uid)? '' : ' AND ( node_uid = '.protect($node_uid).' OR node_uid = "" OR node_uid IS NULL )') );
Base
1
protected function _chmod($path, $mode) { $modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode)); return @ftp_chmod($this->connect, $modeOct, $path); }
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 (!$deep || false === $pos = strpos($key, '[')) { return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default; } $root = substr($key, 0, $pos); if (!array_key_exists($root, $this->parameters)) { return $default; } $value = $this->parameters[$root]; $currentKey = null; for ($i = $pos, $c = strlen($key); $i < $c; ++$i) { $char = $key[$i]; if ('[' === $char) { if (null !== $currentKey) { throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "[" at position %d.', $i)); } $currentKey = ''; } elseif (']' === $char) { if (null === $currentKey) { throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "]" at position %d.', $i)); } if (!is_array($value) || !array_key_exists($currentKey, $value)) { return $default; } $value = $value[$currentKey]; $currentKey = null; } else { if (null === $currentKey) { throw new \InvalidArgumentException(sprintf('Malformed path. Unexpected "%s" at position %d.', $char, $i)); } $currentKey .= $char; } } if (null !== $currentKey) { throw new \InvalidArgumentException(sprintf('Malformed path. Path must end with "]".')); } return $value; }
Base
1
$this->params = $this->convertPartsToParams(); } elseif (isset($_SERVER['REQUEST_URI'])) { // if we hit here, we don't really need to do much. All the pertinent info will come thru in the POST/GET vars // so we don't really need to worry about what the URL looks like. if ($_SERVER['REQUEST_URI'] == PATH_RELATIVE) { $this->url_type = 'base'; $this->params = array(); } else { $sefPath = explode('%22%3E',$_SERVER['REQUEST_URI']); // remove any attempts to close the command $_SERVER['REQUEST_URI'] = $sefPath[0]; $this->url_style = 'query'; } } else { $this->url_type = 'base'; $this->params = array(); } // Check if this was a printer friendly link request define('PRINTER_FRIENDLY', (isset($_REQUEST['printerfriendly']) || isset($this->params['printerfriendly'])) ? 1 : 0); define('EXPORT_AS_PDF', (isset($_REQUEST['exportaspdf']) || isset($this->params['exportaspdf'])) ? 1 : 0); define('EXPORT_AS_PDF_LANDSCAPE', (isset($_REQUEST['landscapepdf']) || isset($this->params['landscapepdf'])) ? 1 : 0); }
Base
1
function categoryBreadcrumb() { // global $db, $router; //eDebug($this->category); /*if(isset($router->params['action'])) { $ancestors = $this->category->pathToNode(); }else if(isset($router->params['section'])) { $current = $db->selectObject('section',' id= '.$router->params['section']); $ancestors[] = $current; if( $current->parent != -1 || $current->parent != 0 ) { while ($db->selectObject('section',' id= '.$router->params['section']);) if ($section->id == $id) { $current = $section; break; } } } eDebug($sections); $ancestors = $this->category->pathToNode(); }*/ $ancestors = $this->category->pathToNode(); // eDebug($ancestors); assign_to_template(array( 'ancestors' => $ancestors )); }
Base
1
function move_standalone() { expSession::clearAllUsersSessionCache('navigation'); assign_to_template(array( 'parent' => $this->params['parent'], )); }
Base
1
function edit_internalalias() { $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params); if ($section->parent == -1) { notfoundController::handle_not_found(); exit; } // doesn't work for standalone pages if (empty($section->id)) { $section->public = 1; if (!isset($section->parent)) { // This is another precaution. The parent attribute // should ALWAYS be set by the caller. //FJD - if that's the case, then we should die. notfoundController::handle_not_authorized(); exit; //$section->parent = 0; } } assign_to_template(array( 'section' => $section, 'glyphs' => self::get_glyphs(), )); }
Base
1
public function stripClean($str) { return $this->xssClean($this->stripTags($str)); }
Base
1
self::get($arr); } else { self::incFront('default'); } }
Base
1
function send_feedback() { $success = false; if (isset($this->params['id'])) { $ed = new eventdate($this->params['id']); // $email_addrs = array(); if ($ed->event->feedback_email != '') { $msgtemplate = expTemplate::get_template_for_action($this, 'email/_' . $this->params['formname'], $this->loc); $msgtemplate->assign('params', $this->params); $msgtemplate->assign('event', $ed); $email_addrs = explode(',', $ed->event->feedback_email); //This is an easy way to remove duplicates $email_addrs = array_flip(array_flip($email_addrs)); $email_addrs = array_map('trim', $email_addrs); $mail = new expMail(); $success += $mail->quickSend(array( "text_message" => $msgtemplate->render(), 'to' => $email_addrs, 'from' => !empty($this->params['email']) ? $this->params['email'] : trim(SMTP_FROMADDRESS), 'subject' => $this->params['subject'], )); } } if ($success) { flashAndFlow('message', gt('Your feedback was successfully sent.')); } else { flashAndFlow('error', gt('We could not send your feedback. Please contact your administrator.')); } }
Base
1
function _makeChooseCheckbox($value, $title) { global $THIS_RET; // return '<INPUT type=checkbox name=st_arr[] value=' . $value . ' checked>'; return "<input name=unused[$THIS_RET[STUDENT_ID]] value=" . $THIS_RET[STUDENT_ID] . " type='checkbox' id=$THIS_RET[STUDENT_ID] onClick='setHiddenCheckboxStudents(\"st_arr[]\",this,$THIS_RET[STUDENT_ID]);' />"; }
Base
1
public static function inFolder() { $uri = explode('/', Site::$url); if(count($uri) > 3) { return true; }else{ return false; } }
Base
1
public function create(Codendi_Request $request) { $content_id = false; $vId = new Valid_UInt($this->widget_id . '_job_id'); $vId->setErrorMessage("Can't add empty job id"); $vId->required(); if ($request->valid($vId)) { $job_id = $request->get($this->widget_id . '_job_id'); $sql = 'INSERT INTO plugin_hudson_widget (widget_name, owner_id, owner_type, job_id) VALUES ("' . $this->id . '", ' . $this->owner_id . ", '" . $this->owner_type . "', " . db_escape_int($job_id) . " )"; $res = db_query($sql); $content_id = db_insertid($res); } return $content_id; }
Base
1
public static function set_session($vars) { if (is_array($vars)) { if(is_array($_SESSION['gxsess']['val'])){ $arr = array_merge($_SESSION['gxsess']['val'], $vars); $_SESSION['gxsess']['val'] = $arr; }else{ $_SESSION['gxsess']['val'] = $vars; } } }
Base
1
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 quicksearch($text) { global $DB; global $website; $like = ' LIKE '.protect('%'.$text.'%'); // we search for the IDs at the dictionary NOW (to avoid inefficient requests) $DB->query('SELECT DISTINCT (nvw.node_id) FROM nv_webdictionary nvw WHERE nvw.node_type = "feed" AND nvw.website = '.$website->id.' AND nvw.text '.$like, 'array'); $dict_ids = $DB->result("node_id"); // all columns to look for $cols[] = 'i.id' . $like; if(!empty($dict_ids)) $cols[] = 'i.id IN ('.implode(',', $dict_ids).')'; $where = ' AND ( '; $where.= implode( ' OR ', $cols); $where .= ')'; return $where; }
Base
1
function VerifyBlockedSchedule($columns,$course_period_id,$sec,$edit=false) { if($course_period_id!='new') { $cp_det_RET= DBGet(DBQuery("SELECT * FROM course_periods WHERE course_period_id=$course_period_id")); $cp_det_RET=$cp_det_RET[1]; $teacher=$cp_det_RET['TEACHER_ID']; $secteacher=$cp_det_RET['SECONDARY_TEACHER_ID']; $all_teacher=$teacher.($secteacher!=''?$secteacher:''); }
Base
1
$parent = $dIF->getItemFromDb($item->getParentId()); $content .= '<tr>'; $content .= '<td>' . '<a href="/plugins/docman/?group_id=' . $params['group_id'] . '&action=details&id=' . $item->getId() . '">' . $item->getTitle() . '</a></td>'; $content .= '<td>'; if ($parent === null || $dIF->isRoot($parent)) { $content .= '</td>'; } else { $content .= '<a href="' . $this->defaultUrl . '&action=show&id=' . $parent->getId() . '">' . $parent->getTitle() . '</a></td>'; } $content .= '<td>' . $hp->purify($uH->getDisplayNameFromUserId($row['user_id'])) . '</td>'; $content .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['lock_date']) . '</td>'; $content .= '</tr>'; } }
Base
1
public function update_groupdiscounts() { global $db; if (empty($this->params['id'])) { // look for existing discounts for the same group $existing_id = $db->selectValue('groupdiscounts', 'id', 'group_id='.$this->params['group_id']); if (!empty($existing_id)) flashAndFlow('error',gt('There is already a discount for that group.')); } $gd = new groupdiscounts(); $gd->update($this->params); expHistory::back(); }
Base
1
public static function deactivate($mod){ $mods = Options::v('modules'); $mods = json_decode($mods, true); if (!is_array($mods) || $mods == "") { $mods = array(); } //print_r($mods); $arr = ""; for ($i=0;$i<count($mods);$i++) { # code... if ($mods[$i] == $mod) { //unset($mods[$i]); }else{ $arr[] = $mods[$i]; } } //print_r($arr); //asort($mods); $mods = json_encode($arr); $mods = Options::update('modules', $mods); if($mods){ new Options(); return true; }else{ return false; } }
Base
1
public function disable() { $this->checkCSRFParam(); $project = $this->getProject(); $swimlane_id = $this->request->getIntegerParam('swimlane_id'); if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) { $this->flash->success(t('Swimlane updated successfully.')); } else { $this->flash->failure(t('Unable to update this swimlane.')); } $this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id']))); }
Class
2
public static function canImportData() { return true; }
Class
2
public function confirm() { $project = $this->getProject(); $category = $this->getCategory(); $this->response->html($this->helper->layout->project('category/remove', array( 'project' => $project, 'category' => $category, ))); }
Base
1
public function &storeicms_ipf_Object($debug=false, $xparam = false) { $ret =& $this->storeFromDefaultForm('', '', null, $debug, $xparam); return $ret; }
Base
1
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(); }
Base
1
public function post() { $args = $_POST; foreach ($this->dbFields as $key=>$value) { if (isset($args[$key])) { $value = Sanitize::html( $args[$key] ); if ($value==='false') { $value = false; } elseif ($value==='true') { $value = true; } settype($value, gettype($this->dbFields[$key])); $this->db[$key] = $value; } } return $this->save(); }
Base
1
public function createTag($name, $options = NULL) { $this->run('tag', $options, $name); return $this; }
Class
2
public function confirm() { $task = $this->getTask(); $link = $this->getTaskLink(); $this->response->html($this->template->render('task_internal_link/remove', array( 'link' => $link, 'task' => $task, ))); }
Base
1
function edit_internalalias() { $section = isset($this->params['id']) ? $this->section->find($this->params['id']) : new section($this->params); if ($section->parent == -1) { notfoundController::handle_not_found(); exit; } // doesn't work for standalone pages if (empty($section->id)) { $section->public = 1; if (!isset($section->parent)) { // This is another precaution. The parent attribute // should ALWAYS be set by the caller. //FJD - if that's the case, then we should die. notfoundController::handle_not_authorized(); exit; //$section->parent = 0; } } assign_to_template(array( 'section' => $section, 'glyphs' => self::get_glyphs(), )); }
Class
2
public function editspeed() { global $db; if (empty($this->params['id'])) return false; $calcname = $db->selectValue('shippingcalculator', 'calculator_name', 'id='.$this->params['id']); $calc = new $calcname($this->params['id']); assign_to_template(array( 'calculator'=>$calc )); }
Base
1
public static function delete($id){ $id = sprintf('%d', $id); $parent = self::getParent($id); $sql = array( 'table' => 'cat', 'where' => array( 'id' => $id ) ); $cat = Db::delete($sql); if($cat){ return true; }else{ return false; } // check all posts with this category and move to parent categories $post = Db::result("SELECT `id` FROM `posts` WHERE `cat` = '{$id}'"); $npost = Db::$num_rows; //print_r($parent); if($npost > 0){ $sql = "UPDATE `posts` SET `cat` = '{$parent[0]->parent}' WHERE `cat` = '{$id}'"; Db::query($sql); } }
Base
1
public function __destruct() { if (class_exists('ZipArchive')) { $this->Zip->close(); } }
Base
1
public function testComments() { $antiXss = new \MicroweberPackages\Helper\HTMLClean(); $string = '<a href="https://example.com">test</a>'; $content = $antiXss->onlyTags($string); $this->assertEquals($string, $content); }
Base
1
protected function getFooService() { $a = new \App\Bar(); $b = new \App\Baz($a); $b->bar = $a; $this->services['App\Foo'] = $instance = new \App\Foo($b); $a->foo = $instance; return $instance; }
Base
1
public function backup($type='json') { global $DB; global $website; $out = array(); $DB->query('SELECT * FROM nv_items WHERE website = '.protect($website->id), 'object'); if($type='json') $out = json_encode($DB->result()); return $out; }
Base
1
public static function checkPermissions($permission,$location) { global $exponent_permissions_r, $router; // only applies to the 'manage' method if (empty($location->src) && empty($location->int) && (!empty($router->params['action']) && $router->params['action'] == 'manage') || strpos($router->current_url, 'action=manage') !== false) { if (!empty($exponent_permissions_r['navigation'])) foreach ($exponent_permissions_r['navigation'] as $page) { foreach ($page as $pageperm) { if (!empty($pageperm['manage'])) return true; } } } return false; }
Class
2
$logo = "<img src=\"".Options::get('siteurl').Options::get('logo')."\" style=\"width: $width; height: $height; margin: 1px;\">"; }else{ $logo = "<span class=\"mg genixcms-logo\"></span>"; } return $logo; }
Compound
4
protected function _filePutContents($path, $content) { return $this->query(sprintf('UPDATE %s SET content="%s", size=%d, mtime=%d WHERE id=%d LIMIT 1', $this->tbf, $this->db->real_escape_string($content), strlen($content), time(), $path)); }
Base
1
function addDiscountToCart() { // global $user, $order; global $order; //lookup discount to see if it's real and valid, and not already in our cart //this will change once we allow more than one coupon code $discount = new discounts(); $discount = $discount->getCouponByName($this->params['coupon_code']); if (empty($discount)) { flash('error', gt("This discount code you entered does not exist.")); //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); expHistory::back(); } //check to see if it's in our cart already if ($this->isDiscountInCart($discount->id)) { flash('error', gt("This discount code is already in your cart.")); //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); expHistory::back(); } //this should really be reworked, as it shoudn't redirect directly and not return $validateDiscountMessage = $discount->validateDiscount(); if ($validateDiscountMessage == "") { //if all good, add to cart, otherwise it will have redirected $od = new order_discounts(); $od->orders_id = $order->id; $od->discounts_id = $discount->id; $od->coupon_code = $discount->coupon_code; $od->title = $discount->title; $od->body = $discount->body; $od->save(); // set this to just the discount applied via this coupon?? if so, when though? $od->discount_total = ??; flash('message', gt("The discount code has been applied to your cart.")); } else { flash('error', $validateDiscountMessage); } //redirect_to(array('controller'=>'cart', 'action'=>'checkout')); expHistory::back(); }
Class
2
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
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)); }
Base
1
public function testRemoveCurlAuthorizationOptionsOnRedirect($auth) { if (!defined('\CURLOPT_HTTPAUTH')) { self::markTestSkipped('ext-curl is required for this test'); } $mock = new MockHandler([ new Response(302, ['Location' => 'http://test.com']), static function (RequestInterface $request, $options) { self::assertFalse( isset($options['curl'][\CURLOPT_HTTPAUTH]), 'curl options still contain CURLOPT_HTTPAUTH entry' ); self::assertFalse( isset($options['curl'][\CURLOPT_USERPWD]), 'curl options still contain CURLOPT_USERPWD entry' ); return new Response(200); } ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); $client->get('http://example.com?a=b', ['auth' => ['testuser', 'testpass', $auth]]); }
Class
2
public function isAllowedFilename($filename){ $allow_array = array( '.jpg','.jpeg','.png','.bmp','.gif','.ico','.webp', '.mp3','.wav','.mp4', '.mov','.webmv','.flac','.mkv', '.zip','.tar','.gz','.tgz','.ipa','.apk','.rar','.iso', '.pdf','.ofd','.swf','.epub','.xps', '.doc','.docx','.wps', '.ppt','.pptx','.xls','.xlsx','.txt','.psd','.csv', '.cer','.ppt','.pub','.json','.css', ) ; $ext = strtolower(substr($filename,strripos($filename,'.')) ); //获取文件扩展名(转为小写后) if(in_array( $ext , $allow_array ) ){ return true ; } return false; }
Base
1
function selectArraysBySql($sql) { $res = @mysqli_query($this->connection, $this->injectProof($sql)); if ($res == null) return array(); $arrays = array(); for ($i = 0, $iMax = mysqli_num_rows($res); $i < $iMax; $i++) $arrays[] = mysqli_fetch_assoc($res); return $arrays; }
Base
1
foreach ($data['alertred'] as $alert) { # code... echo "<li>$alert</li>\n"; }
Compound
4
function _makeChooseCheckbox($value, $title) { // return '<INPUT type=checkbox name=st_arr[] value=' . $value . ' checked>'; global $THIS_RET; return "<input name=unused[$THIS_RET[STUDENT_ID]] value=" . $THIS_RET[STUDENT_ID] . " type='checkbox' id=$THIS_RET[STUDENT_ID] onClick='setHiddenCheckboxStudents(\"st_arr[]\",this,$THIS_RET[STUDENT_ID]);' />"; }
Base
1
public function newModel() { return new APIModel('testuser','5f4dcc3b5aa765d61d8327deb882cf99',rtrim(TEST_BASE_URL,'/')); }
Class
2
protected function _move($source, $targetDir, $name) { $target = $this->_joinPath($targetDir, $name); return $this->connect->rename($source, $target) ? $target : false; }
Base
1
public static function install () { include(GX_PATH.'/inc/lib/Control/Install/default.control.php'); }
Base
1
public function confirm() { $project = $this->getProject(); $swimlane = $this->getSwimlane(); $this->response->html($this->helper->layout->project('swimlane/remove', array( 'project' => $project, 'swimlane' => $swimlane, ))); }
Class
2
public function get_items( $request ) { $sked = get_template_sked( $request['post_id'] ); return new WP_REST_Response( $sked, 200 ); }
Base
1
function db_case($array) { global $DatabaseType; $counter = 0; if ($DatabaseType == 'mysqli') { $array_count = count($array); $string = " CASE WHEN $array[0] ="; $counter++; $arr_count = count($array); for ($i = 1; $i < $arr_count; $i++) { $value = $array[$i]; if ($value == "''" && substr($string, -1) == '=') { $value = ' IS NULL'; $string = substr($string, 0, -1); } $string .= "$value"; if ($counter == ($array_count - 2) && $array_count % 2 == 0) $string .= " ELSE "; elseif ($counter == ($array_count - 1)) $string .= " END "; elseif ($counter % 2 == 0) $string .= " WHEN $array[0]="; elseif ($counter % 2 == 1) $string .= " THEN "; $counter++; } } return $string; }
Base
1
public 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 activate_discount(){ if (isset($this->params['id'])) { $discount = new discounts($this->params['id']); $discount->update($this->params); //if ($discount->discountulator->hasConfig() && empty($discount->config)) { //flash('messages', $discount->discountulator->name().' requires configuration. Please do so now.'); //redirect_to(array('controller'=>'billing', 'action'=>'configure', 'id'=>$discount->id)); //} } expHistory::back(); }
Base
1
public function confirm() { $task = $this->getTask(); $comment = $this->getComment(); $this->response->html($this->template->render('comment/remove', array( 'comment' => $comment, 'task' => $task, 'title' => t('Remove a comment') ))); }
Base
1
public static function returnChildrenAsJSON() { global $db; //$nav = section::levelTemplate(intval($_REQUEST['id'], 0)); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $nav = $db->selectObjects('section', 'parent=' . $id, 'rank'); //FIXME $manage_all is moot w/ cascading perms now? $manage_all = false; if (expPermissions::check('manage', expCore::makeLocation('navigation', '', $id))) { $manage_all = true; } //FIXME recode to use foreach $key=>$value $navcount = count($nav); for ($i = 0; $i < $navcount; $i++) { if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigation', '', $nav[$i]->id))) { $nav[$i]->manage = 1; $view = true; } else { $nav[$i]->manage = 0; $view = $nav[$i]->public ? true : expPermissions::check('view', expCore::makeLocation('navigation', '', $nav[$i]->id)); } $nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name); if (!$view) unset($nav[$i]); } $nav= array_values($nav); // $nav[$navcount - 1]->last = true; if (count($nav)) $nav[count($nav) - 1]->last = true; // echo expJavascript::ajaxReply(201, '', $nav); $ar = new expAjaxReply(201, '', $nav); $ar->send(); }
Class
2
public static function initializeNavigation() { $sections = section::levelTemplate(0, 0); return $sections; }
Base
1
$incident_title = strip_tags(html_entity_decode(html_entity_decode($this->data->item_title, ENT_QUOTES)));
Base
1
public function save() { global $DB; // remove all old entries $node_id_filter = ''; if(!empty($this->node_id)) { if(is_numeric($this->node_id)) $node_id_filter .= ' AND node_id = '.intval($this->node_id); if(is_numeric($this->node_uid)) $node_id_filter .= ' AND node_uid = '.intval($this->node_uid); $DB->execute(' DELETE FROM nv_webdictionary WHERE website = '.protect($this->website).' AND subtype = '.protect($this->subtype).' AND theme = '.protect($this->theme).' AND extension = '.protect($this->extension).' AND node_type = '.protect($this->node_type). $node_id_filter ); } // insert the new ones return $this->insert(); }
Base
1
public static function load($mod) { $file = GX_MOD."/".$mod."/index.php"; if(file_exists($file)){ include ($file); } }
Base
1
return @unlink($dir); } return false; }
Base
1
print "<option value='" . $device['id'] . "'"; if (get_request_var('host_id') == $device['id']) { print ' selected'; } print '>' . title_trim(htmlspecialchars($device['description'] . ' (' . $device['hostname'] . ')'), 40) . "</option>\n"; } } ?> </select> </td> <?php } else {
Base
1
function delete() { global $db; if (empty($this->params['id'])) return false; $product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']); $product = new $product_type($this->params['id'], true, false); //eDebug($product_type); //eDebug($product, true); //if (!empty($product->product_type_id)) { //$db->delete($product_type, 'id='.$product->product_id); //} $db->delete('option', 'product_id=' . $product->id . " AND optiongroup_id IN (SELECT id from " . $db->prefix . "optiongroup WHERE product_id=" . $product->id . ")"); $db->delete('optiongroup', 'product_id=' . $product->id); //die(); $db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type="' . $product_type . '"'); if ($product->product_type == "product") { if ($product->hasChildren()) { $this->deleteChildren(); } } $product->delete(); flash('message', gt('Product deleted successfully.')); expHistory::back(); }
Base
1
public static function getTemplateHierarchyFlat($parent, $depth = 1) { global $db; $arr = array(); $kids = $db->selectObjects('section_template', 'parent=' . $parent, 'rank'); // $kids = expSorter::sort(array('array'=>$kids,'sortby'=>'rank', 'order'=>'ASC')); for ($i = 0, $iMax = count($kids); $i < $iMax; $i++) { $page = $kids[$i]; $page->depth = $depth; $page->first = ($i == 0 ? 1 : 0); $page->last = ($i == count($kids) - 1 ? 1 : 0); $arr[] = $page; $arr = array_merge($arr, self::getTemplateHierarchyFlat($page->id, $depth + 1)); } return $arr; }
Base
1
public static function rss() { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/rss".GX_URL_PREFIX; break; default: # code... $url = Options::get('siteurl')."/index.php?rss"; break; } return $url; }
Compound
4
public function StartTLS() { $this->error = null; # to avoid confusion if(!$this->connected()) { $this->error = array("error" => "Called StartTLS() without being connected"); return false; } fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); $rply = $this->get_lines(); $code = substr($rply,0,3); if($this->do_debug >= 2) { $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); } if($code != 220) { $this->error = array("error" => "STARTTLS not accepted from server", "smtp_code" => $code, "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); } return false; } // Begin encrypted connection if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { return false; } return true; }
Base
1
function check_app_exists($uniq_name, $bdd) { $sql = "select count(*) from bp where name = '" . $uniq_name . "';"; $req = $bdd->query($sql); $bp_exist = $req->fetch(PDO::FETCH_NUM); if($bp_exist[0] == 1){ echo "true"; } else { echo "false"; } }
Base
1
public function validate() { global $db; // check for an sef url field. If it exists make sure it's valid and not a duplicate //this needs to check for SEF URLS being turned on also: TODO if (property_exists($this, 'sef_url') && !(in_array('sef_url', $this->do_not_validate))) { if (empty($this->sef_url)) $this->makeSefUrl(); if (!isset($this->validates['is_valid_sef_name']['sef_url'])) $this->validates['is_valid_sef_name']['sef_url'] = array(); if (!isset($this->validates['uniqueness_of']['sef_url'])) $this->validates['uniqueness_of']['sef_url'] = array(); } // safeguard again loc data not being pass via forms...sometimes this happens when you're in a router // mapped view and src hasn't been passed in via link to the form if (isset($this->id) && empty($this->location_data)) { $loc = $db->selectValue($this->tablename, 'location_data', 'id=' . $this->id); if (!empty($loc)) $this->location_data = $loc; } // run the validation as defined in the models if (!isset($this->validates)) return true; $messages = array(); $post = empty($_POST) ? array() : expString::sanitize($_POST); foreach ($this->validates as $validation=> $field) { foreach ($field as $key=> $value) { $fieldname = is_numeric($key) ? $value : $key; $opts = is_numeric($key) ? array() : $value; $ret = expValidator::$validation($fieldname, $this, $opts); if (!is_bool($ret)) { $messages[] = $ret; expValidator::setErrorField($fieldname); unset($post[$fieldname]); } } } if (count($messages) >= 1) expValidator::failAndReturnToForm($messages, $post); }
Base
1
public static function post($vars) { switch (SMART_URL) { case true: # code... $url = Options::get('siteurl')."/".self::slug($vars)."/{$vars}"; break; default: # code... $url = Options::get('siteurl')."/index.php?post={$vars}"; break; } return $url; }
Base
1
public function update_version() { // get the current version $hv = new help_version(); $current_version = $hv->find('first', 'is_current=1'); // check to see if the we have a new current version and unset the old current version. if (!empty($this->params['is_current'])) { // $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0'); help_version::clearHelpVersion(); } expSession::un_set('help-version'); // save the version $id = empty($this->params['id']) ? null : $this->params['id']; $version = new help_version(); // if we don't have a current version yet so we will force this one to be it if (empty($current_version->id)) $this->params['is_current'] = 1; $version->update($this->params); // if this is a new version we need to copy over docs if (empty($id)) { self::copydocs($current_version->id, $version->id); } // let's update the search index to reflect the current help version searchController::spider(); flash('message', gt('Saved help version').' '.$version->version); expHistory::back(); }
Base
1
public function getQueryGroupby() { return "a.per_tracker_artifact_id"; }
Base
1