public function IsStrongCondition() { if (stripos($this->Conditions, " or ") !== false) { return true; } return false; }
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { $db = $this->getDbo(); /** @var $db JDatabaseMySQLi */ // Create a new query object. $query = $db->getQuery(true); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.record_date, a.votes, a.item_id, ' . 'b.title, ' . 'c.name')); $query->from($db->quoteName('#__uideas_votes') . ' AS a'); $query->innerJoin($db->quoteName('#__uideas_items') . ' AS b ON a.item_id = b.id'); $query->leftJoin($db->quoteName('#__users') . ' AS c ON a.user_id = c.id'); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $escaped = $db->escape($search, true); $quoted = $db->quote("%" . $escaped . "%", false); $query->where('b.title LIKE ' . $quoted, "OR"); $query->where('c.name LIKE ' . $quoted); } } // Add the list ordering clause. $orderString = $this->getOrderString(); $query->order($db->escape($orderString)); return $query; }
/** * Alter the Environment Internal Encoding if it is not utf-8 * * @return void */ protected function saveInternalEncoding() { $this->encoding = mb_internal_encoding(); if (stripos($this->encoding, 'utf-8') === false) { mb_internal_encoding('UTF-8'); } }
/** * Implements EntityReferenceHandler::getReferencableEntities(). */ public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { $settings = $this->field['settings']['handler_settings']; $include_space = $settings['include_space']; $all_groups = oa_core_get_all_groups(); $groups = array_map(create_function('$group', 'return $group->title;'), $all_groups); $group_options = array(); $count = 0; foreach ($groups as $nid => $group_name) { $count++; if (!$match || stripos($group_name, $match) !== FALSE) { $group_options[$nid] = $group_name; } if ($limit && $count == $limit) { break; } } if ($space_id = oa_core_get_space_context()) { // Bring current group to front. if (!empty($group_options[$space_id])) { $group_options = array($space_id => t('!name (current)', array('!name' => $group_options[$space_id]))) + $group_options; } elseif ($include_space) { $group_options = array($space_id => t('- All space members -')) + $group_options; } } return array(OA_GROUP_TYPE => $group_options); }
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); /** @var $db JDatabaseDriver */ $query = $db->getQuery(true); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.name, a.code, a.code4, a.latitude, a.longitude, a.timezone')); $query->from($db->quoteName('#__crowdf_countries', 'a')); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $escaped = $db->escape($search, true); $quoted = $db->quote("%" . $escaped . "%", false); $query->where('a.name LIKE ' . $quoted); } } // Add the list ordering clause. $orderString = $this->getOrderString(); $query->order($db->escape($orderString)); return $query; }
/** * Method to build an SQL query to load the list data. * * @return string An SQL query */ protected function getListQuery() { $db = $this->getDbo(); $query = $db->getQuery(true); $query->select("u.*"); $query->from("#__bt_user_fields AS u"); $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('u.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('(u.name LIKE ' . $search . ' OR u.type LIKE ' . $search . ')'); } } $fieldtype = $this->getState('filter.fieldtype'); if (!empty($fieldtype)) { $query->where(' u.type ="' . $fieldtype . '"'); } // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('u.published = ' . (int) $published); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol == 'u.ordering') { $orderCol = 'u.ordering'; } $query->order($db->escape($orderCol . ' ' . $orderDirn)); $query->order($db->escape($orderCol . ' ' . $orderDirn)); return $query; }
/** * Constructor. * * @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0 */ public function __construct($classLoader) { $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile'); if ($this->wasFinder) { @trigger_error('The ' . __METHOD__ . ' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED); $this->classLoader = array($classLoader, 'loadClass'); $this->isFinder = true; } else { $this->classLoader = $classLoader; $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile'); } if (!isset(self::$caseCheck)) { $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR); $i = strrpos($file, DIRECTORY_SEPARATOR); $dir = substr($file, 0, 1 + $i); $file = substr($file, 1 + $i); $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file); $test = realpath($dir . $test); if (false === $test || false === $i) { // filesystem is case sensitive self::$caseCheck = 0; } elseif (substr($test, -strlen($file)) === $file) { // filesystem is case insensitive and realpath() normalizes the case of characters self::$caseCheck = 1; } elseif (false !== stripos(PHP_OS, 'darwin')) { // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters self::$caseCheck = 2; } else { // filesystem case checks failed, fallback to disabling them self::$caseCheck = 0; } } }
function azuratestimonial_sc($atts, $content = "") { extract(shortcode_atts(array('id' => '', 'class' => 'pesbox', 'name' => '', 'email' => '', 'avatar' => '', 'position' => '', 'review' => '5', 'layout' => ''), $atts)); $styleArr = shortcode_atts(array('margin_top' => '', 'margin_right' => '', 'margin_bottom' => '', 'margin_left' => '', 'border_top_width' => '', 'border_right_width' => '', 'border_bottom_width' => '', 'border_left_width' => '', 'padding_top' => '', 'padding_right' => '', 'padding_bottom' => '', 'padding_left' => '', 'border_color' => '', 'border_style' => '', 'background_color' => '', 'background_image' => '', 'background_repeat' => '', 'background_attachment' => '', 'background_size' => '', 'additional_style' => '', 'simplified' => ''), $atts); $styleTextArr = CthShortcodes::parseStyle($styleArr); $testimonialstyle = ''; $styleText = implode(" ", $styleTextArr); $styleTextTest = trim($styleText); if (!empty($styleTextTest)) { $testimonialstyle .= trim($styleText); } if (!empty($testimonialstyle)) { $testimonialstyle = 'style="' . $testimonialstyle . '"'; } $animationArgs = shortcode_atts(array('animation' => '0', 'trigger' => 'animate', 'animationtype' => '', 'animationdelay' => ''), $atts); $shortcodeTemp = false; if (stripos($layout, '_:') !== false) { $shortcodeTemp = JPATH_PLUGINS . '/system/cthshortcodes/shortcodes_template/' . substr($layout, 2) . '.php'; } else { if (stripos($layout, ':') !== false) { $shortcodeTemp = CthShortcodes::templatePath() . '/html/com_azurapagebuilder/plugin/shortcodes_template/' . substr($layout, stripos($layout, ':') + 1) . '.php'; } else { $shortcodeTemp = CthShortcodes::addShortcodeTemplate('azuratestimonial'); } } $buffer = ob_get_clean(); ob_start(); if ($shortcodeTemp !== false) { require $shortcodeTemp; } $content = ob_get_clean(); ob_start(); echo $buffer; return $content; }
function file_upload($html) { // Define wp upload folder $main_path = wp_upload_dir(); $current_path = ''; // Instaniate Post_Get class $get = new Post_Get(); // Check if GET variable has value $get->exists('GET'); $current_path = $get->get('upload_dir'); // Define the folder directory that will hold the content $container = $main_path['basedir'] . '/upload_dir'; // Create upload_dir folder to hold the documents that will be uploaded if (!file_exists($container)) { mkdir($container, 0755, true); } // Define current url $current_url = $main_path['baseurl'] . '/upload_dir/'; // Scan current directory $current_dir = scandir($main_path['basedir'] . '/upload_dir/' . $current_path); // Wrap the retusts in unordered list $html .= "<ul>"; // Loop throught current folder foreach ($current_dir as $file) { if (stripos($file, '.') !== 0) { if (strpos($file, '.html') > -1) { $html .= '<li><a href="' . $current_url . $current_path . '/' . $file . '">' . $file . '</a></li>'; } else { $html .= '<li><a href="?upload_dir=' . $current_path . '/' . $file . '">' . $file . '</a></li>'; } } } $html .= '</ul>'; return $html; }
public function handle($request, \Closure $next) { $agent = ""; if (stripos($request->header('user_agent'), 'Firefox') !== false) { $agent = 'Firefox'; } elseif (stripos($request->header('user_agent'), 'MSIE') !== false) { $agent = 'IE'; } elseif (stripos($request->header('user_agent'), 'iPad') !== false) { $agent = 'iPad'; } elseif (stripos($request->header('user_agent'), 'Android') !== false) { $agent = 'Android'; } elseif (stripos($request->header('user_agent'), 'Chrome') !== false) { $agent = 'Chrome'; } elseif (stripos($request->header('user_agent'), 'Safari') !== false) { $agent = 'Safari'; } elseif (stripos($request->header('user_agent'), 'AIR') !== false) { $agent = 'Air'; } elseif (stripos($request->header('user_agent'), 'Fluid') !== false) { $agent = 'Fluid'; } if ($agent == "") { $agent = 'Terminal'; } file_put_contents('log', '/' . $request->path() . ' ' . $agent . "\r\n", FILE_APPEND); return $next($request); }
/** * Returns an object list * * @param string The query * @param int Offset * @param int The number of records * @return array */ protected function _getList($query, $limitstart = 0, $limit = 0) { $ordering = $this->getState('list.ordering'); $search = $this->getState('filter.search'); // Replace slashes so preg_match will work $search = str_replace('/', ' ', $search); $db = $this->getDbo(); if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) { $db->setQuery($query); $result = $db->loadObjectList(); $lang = JFactory::getLanguage(); $this->translate($result); if (!empty($search)) { foreach ($result as $i => $item) { if (!preg_match("/{$search}/i", $item->name)) { unset($result[$i]); } } } JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale()); $total = count($result); $this->cache[$this->getStoreId('getTotal')] = $total; if ($total < $limitstart) { $limitstart = 0; $this->setState('list.start', 0); } return array_slice($result, $limitstart, $limit ? $limit : null); } else { $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction')); $result = parent::_getList($query, $limitstart, $limit); $this->translate($result); return $result; } }
function ajax_query() { // options $options = acf_parse_args($_POST, array('post_id' => 0, 's' => '', 'field_key' => '', 'nonce' => '')); // load field $field = acf_get_field($options['field_key']); if (!$field) { die; } // vars $r = array(); $s = false; // search if ($options['s'] !== '') { // search may be integer $s = strval($options['s']); // strip slashes $s = wp_unslash($s); } // loop through choices if (!empty($field['choices'])) { foreach ($field['choices'] as $k => $v) { // if searching, but doesn't exist if ($s !== false && stripos($v, $s) === false) { continue; } // append $r[] = array('id' => $k, 'text' => strval($v)); } } // return JSON echo json_encode($r); die; }
public function onEvent(GenericEvent $event, $eventName) { if (!$this->enforceHttps) { return; } $nossl = $this->request->get('nossl'); if ($nossl !== null) { $nossl = strtolower($nossl); if ($nossl === 'false' || $nossl === 'off') { $this->response->headers->clearCookie('nossl'); $this->request->cookies->remove('nossl'); } else { $this->response->headers->setCookie(new Cookie('nossl', 'on')); $this->request->cookies->set('nossl', 'on'); } } if (!$this->request->isSecure() && $this->request->cookies->get('nossl') === null) { $ua = $this->request->getUserAgent(); //Unsafe search engine friendly if ($ua !== null && stripos($ua, 'Baiduspider') === false && stripos($ua, 'Sogou web spider') === false && stripos($ua, 'Sosospider') === false) { $this->response->redirect('https://' . $this->request->headers->get('host', $this->canonical) . $this->request->getRequestUri()); $event->stopPropagation(); } } }
function getOS() { if (stripos($_SERVER['SERVER_SOFTWARE'], "win") !== false || stripos(PHP_OS, "win") !== false) { $os = "Windows"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "mac") !== false || stripos(PHP_OS, "mac") !== false || stripos($_SERVER['SERVER_SOFTWARE'], "ppc") !== false || stripos(PHP_OS, "ppc") !== false) { $os = "Mac"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "linux") !== false || stripos(PHP_OS, "linux") !== false) { $os = "Linux"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "freebsd") !== false || stripos(PHP_OS, "freebsd") !== false) { $os = "FreeBSD"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "sunos") !== false || stripos(PHP_OS, "sunos") !== false) { $os = "SunOS"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "irix") !== false || stripos(PHP_OS, "irix") !== false) { $os = "IRIX"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "beos") !== false || stripos(PHP_OS, "beos") !== false) { $os = "BeOS"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "os/2") !== false || stripos(PHP_OS, "os/2") !== false) { $os = "OS/2"; } elseif (stripos($_SERVER['SERVER_SOFTWARE'], "aix") !== false || stripos(PHP_OS, "aix") !== false) { $os = "AIX"; } else { $os = "Autre"; } return $os; }
function ajax_query() { // options $options = acf_parse_args($_GET, array('post_id' => 0, 's' => '', 'field_key' => '', 'nonce' => '')); // load field $field = acf_get_field($options['field_key']); if (!$field) { die; } // vars $r = array(); // strip slashes $options['s'] = wp_unslash($options['s']); if (!empty($field['choices'])) { foreach ($field['choices'] as $k => $v) { // search if ($options['s'] && stripos($v, $options['s']) === false) { continue; } // append $r[] = array('id' => $k, 'text' => strval($v)); } } // return JSON echo json_encode($r); die; }
function form_open($action = '', $attributes = array(), $hidden = array()) { $CI =& get_instance(); // If no action is provided then set to the current url if (!$action) { $action = current_url($action); } elseif (strpos($action, '://') === FALSE) { $action = if_secure_site_url($action); } $attributes = _attributes_to_string($attributes); if (stripos($attributes, 'method=') === FALSE) { $attributes .= ' method="post"'; } if (stripos($attributes, 'accept-charset=') === FALSE) { $attributes .= ' accept-charset="' . strtolower(config_item('charset')) . '"'; } $form = '<form action="' . $action . '"' . $attributes . ">\n"; // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites if ($CI->config->item('csrf_protection') === TRUE && strpos($action, if_secure_base_url()) !== FALSE && !stripos($form, 'method="get"')) { $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } // Add MY CSRF token if MY CSRF library is loaded if ($CI->load->is_loaded('tokens') && strpos($action, if_secure_base_url()) !== FALSE && !stripos($form, 'method="get"')) { $hidden[$CI->tokens->name] = $CI->tokens->token(); } if (is_array($hidden)) { foreach ($hidden as $name => $value) { $form .= '<input type="hidden" name="' . $name . '" value="' . html_escape($value) . '" style="display:none;" />' . "\n"; } } return $form; }
public function filterItem($filters) { foreach ($filters as $filter => $value) { switch ($filter) { case 'search': if (stripos($this->getTitle(), $value) === FALSE && stripos($this->getSubTitle(), $value) === FALSE && stripos($this->getDescription(), $value) === FALSE) { return false; } break; case 'min': if (!isset($center)) { $center = $this->getGeometry()->getCenterCoordinate(); } if ($center['lat'] < $value['lat'] || $center['lon'] < $value['lon']) { return false; } break; case 'max': if (!isset($center)) { $center = $this->getGeometry()->getCenterCoordinate(); } if ($center['lat'] > $value['lat'] || $center['lon'] > $value['lon']) { return false; } break; } } return true; }
/** * 架构函数 取得模板对象实例 * @access public */ public function __construct() { //实例化视图类 $this->view = Think::instance('View'); defined('__EXT__') or define('__EXT__', ''); if ('' == __EXT__ || false === stripos(C('REST_CONTENT_TYPE_LIST'), __EXT__)) { // 资源类型没有指定或者非法 则用默认资源类型访问 $this->_type = C('REST_DEFAULT_TYPE'); } else { $this->_type = __EXT__; } // 请求方式检测 $method = strtolower($_SERVER['REQUEST_METHOD']); if (false === stripos(C('REST_METHOD_LIST'), $method)) { // 请求方式非法 则用默认请求方法 $method = C('REST_DEFAULT_METHOD'); } $this->_method = $method; // 允许输出的资源类型 $this->_types = C('REST_OUTPUT_TYPE'); //控制器初始化 if (method_exists($this, '_initialize')) { $this->_initialize(); } }
function startsWith($haystack, $needle, $case = true) { if ($case) { return strpos($haystack, $needle, 0) === 0; } return stripos($haystack, $needle, 0) === 0; }
/** * @param RepositoryList $repositories */ public function execute(RepositoryList $repositories) { $model = $repositories->getProjectModel(); $currentBranch = $model->getBranch(); if ($model->hasConflicts()) { if (false !== stripos($model->getConflicts(), ComposerHelper::COMPOSER_JSON)) { $this->getSymfonyStyle()->error('You should resolve composer.json conflict first'); $this->stopPropagation(); return; } if (false !== stripos($model->getConflicts(), ComposerHelper::COMPOSER_LOCK)) { try { $this->getLogger()->debug('Auto-resolve composer.lock conflict'); $vendorsForUpdate = $this->findVendorsForUpdate($model); $this->resolveComposerConflict($model, ComposerHelper::COMPOSER_LOCK, $currentBranch); if ($vendorsForUpdate) { $cmd = $this->getConfig()->getComposerBin() . ' update ' . implode(' ', $vendorsForUpdate); $this->getSymfonyStyle()->writeln($cmd); $model->getProvider()->runCommand($cmd, $this->isDryRun(), true); } $model->getProvider()->run('add', [ComposerHelper::COMPOSER_LOCK], $this->isDryRun(), false); } catch (\Exception $e) { $this->getLogger()->error($e->getMessage(), [$e->getTraceAsString()]); $this->getSymfonyStyle()->error($e->getMessage()); $this->stopPropagation(); } } } }
private function _xml_extract($attr, $xml) { $init = stripos($xml, "<" . $attr . ">"); $end_pos = stripos($xml, "</" . $attr . ">"); $init_pos = $init + strlen($attr) + 2; return substr($xml, $init_pos, $end_pos - $init_pos); }
private function getLatestSymfonyVersion() { // Get GitHub JSON request $opts = array('http' => array('method' => "GET", 'header' => "User-Agent: LiipMonitorBundle\r\n")); $context = stream_context_create($opts); $githubUrl = 'https://api.github.com/repos/symfony/symfony/tags'; $githubJSONResponse = file_get_contents($githubUrl, false, $context); // Convert it to a PHP object $githubResponseArray = json_decode($githubJSONResponse, true); if (empty($githubResponseArray)) { throw new \Exception("No valid response or no tags received from GitHub."); } $tags = array(); foreach ($githubResponseArray as $tag) { $tags[] = $tag['name']; } // Sort tags usort($tags, "version_compare"); // Filter out non final tags $filteredTagList = array_filter($tags, function ($tag) { return !stripos($tag, "PR") && !stripos($tag, "RC") && !stripos($tag, "BETA"); }); // The first one is the last stable release for Symfony 2 $reverseFilteredTagList = array_reverse($filteredTagList); return str_replace("v", "", $reverseFilteredTagList[0]); }
private function valueMatches($columnValue, $operator, $expectedValue) { if ($operator == 'eq' && $columnValue == $expectedValue) { return true; } if ($operator == 'not' && $columnValue != $expectedValue) { return true; } if ($operator == 'gt' && $columnValue > $expectedValue) { return true; } if ($operator == 'lt' && $columnValue < $expectedValue) { return true; } if ($operator == 'gte' && $columnValue >= $expectedValue) { return true; } if ($operator == 'lte' && $columnValue <= $expectedValue) { return true; } if ($operator == 'contains' && stripos($columnValue, $expectedValue) !== false) { return true; } if (in_array($operator, ['in', 'notIn']) && !$expectedValue) { throw new \Exception('No expected values for IN clause'); } if ($operator == 'in' && in_array($columnValue, $expectedValue)) { return true; } if ($operator == 'notIn' && !in_array($columnValue, $expectedValue)) { return true; } return false; }
/** * Sets options on a cURL resource based on a request. */ private static function setOptionsFromRequest($curl, RequestInterface $request) { $options = array(CURLOPT_HTTP_VERSION => $request->getProtocolVersion() == 1.0 ? CURL_HTTP_VERSION_1_0 : CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => $request->getMethod(), CURLOPT_URL => $request->getHost() . $request->getResource(), CURLOPT_HTTPHEADER => $request->getHeaders()); switch ($request->getMethod()) { case RequestInterface::METHOD_HEAD: $options[CURLOPT_NOBODY] = true; break; case RequestInterface::METHOD_GET: $options[CURLOPT_HTTPGET] = true; break; case RequestInterface::METHOD_POST: case RequestInterface::METHOD_PUT: case RequestInterface::METHOD_DELETE: case RequestInterface::METHOD_PATCH: case RequestInterface::METHOD_OPTIONS: $options[CURLOPT_POSTFIELDS] = $fields = static::getPostFields($request); // remove the content-type header if (is_array($fields)) { $options[CURLOPT_HTTPHEADER] = array_filter($options[CURLOPT_HTTPHEADER], function ($header) { return 0 !== stripos($header, 'Content-Type: '); }); } break; } curl_setopt_array($curl, $options); }
public static function getLiveScore($requester, $request) { $requestParams = explode(",", $request); $scoreAvailable = false; $team1 = $requestParams[0]; $team2 = $requestParams[1]; $matchList = file_get_contents(self::$cricInfoURL); $message = "Sorry, this match information is not available."; if ($matchList) { $json = json_decode($matchList, true); foreach ($json as $value) { echo $value['t1'] . '/n'; echo $value['t2'] . '/n/n'; if ((stripos($value['t1'], $team1) > -1 || stripos($value['t1'], $team2) > -1) && (stripos($value['t2'], $team1) > -1 || stripos($value['t2'], $team2) > -1)) { $matchScoreURL = self::$cricInfoURL . '?id=' . $value['id']; $matchScore = file_get_contents($matchScoreURL); $matchScore = json_decode($matchScore, true); $score = $matchScore['0']['de']; $scoreAvailable = true; MessaggingController::sendMessage($requester, $score); } } } else { $message = "Service temporarily not available, please try after some time"; } if (!$scoreAvailable) { MessaggingController::sendMessage($requester, $message); } PubSub::publish(GenieConstants::$SERVICE_REQUEST_COMPLETE, $requester); }
public function execute(CommandSender $sender, $currentAlias, array $args) { if (!$this->testPermission($sender)) { return true; } if (count($args) === 0) { $output = "This server is running " . $sender->getServer()->getName() . " version " . $sender->getServer()->getPocketMineVersion() . " 「" . $sender->getServer()->getCodename() . "」 (Implementing API version " . $sender->getServer()->getApiVersion() . " for Minecraft: PE " . $sender->getServer()->getVersion() . " protocol version " . Info::CURRENT_PROTOCOL . ")"; if (\pocketmine\GIT_COMMIT !== str_repeat("00", 20)) { $output .= " [git " . \pocketmine\GIT_COMMIT . "]"; } $sender->sendMessage($output); } else { $pluginName = implode(" ", $args); $exactPlugin = $sender->getServer()->getPluginManager()->getPlugin($pluginName); if ($exactPlugin instanceof Plugin) { $this->describeToSender($exactPlugin, $sender); return true; } $found = false; $pluginName = strtolower($pluginName); foreach ($sender->getServer()->getPluginManager()->getPlugins() as $plugin) { if (stripos($plugin->getName(), $pluginName) !== false) { $this->describeToSender($plugin, $sender); $found = true; } } if (!$found) { $sender->sendMessage("This server is not running any plugin by that name.\nUse /plugins to get a list of plugins."); } } return true; }
/** * Attempt to construct an ODD object out of a XmlElement or sub-elements. * * @param XmlElement $element The element(s) * * @return mixed An ODD object if the element can be handled, or false. */ function ODD_factory(XmlElement $element) { $name = $element->name; $odd = false; switch ($name) { case 'entity': $odd = new ODDEntity("", "", ""); break; case 'metadata': $odd = new ODDMetaData("", "", "", ""); break; case 'relationship': $odd = new ODDRelationship("", "", ""); break; } // Now populate values if ($odd) { // Attributes foreach ($element->attributes as $k => $v) { $odd->setAttribute($k, $v); } // Body $body = $element->content; $a = stripos($body, "<![CDATA"); $b = strripos($body, "]]>"); if ($body && $a !== false && $b !== false) { $body = substr($body, $a + 8, $b - ($a + 8)); } $odd->setBody($body); } return $odd; }
public function where($idsArr, $paramType = array()) { if (is_array($idsArr)) { foreach ($idsArr as $key => $val) { if (is_array($val)) { $Idcount = count($val); if ($Idcount > 1) { $this->where .= ' AND ' . $key . ' in (\'' . implode("','", $val) . '\')'; } else { if ($Idcount == 1) { $this->where .= ' AND ' . $key . ' = \'' . $val[0] . '\''; } } } elseif ($paramType[$key]['fuzzy']) { $this->where .= ' AND ' . $key . ' LIKE \'%' . $val . '%\''; } elseif ($paramType[$key]['math']) { $this->where .= ' AND ' . $key . $paramType[$key]['math'] . ' \'' . $val . '\''; } elseif (is_int($val) || is_float($val) || is_numeric($val)) { $this->where .= ' AND ' . $key . ' = ' . $val; } elseif (is_string($val) && stripos($val, ',') !== false) { $this->where .= ' AND ' . $key . ' in (' . $val . ')'; } elseif (is_string($val)) { $this->where .= ' AND ' . $key . ' = \'' . $val . '\''; } } } elseif (is_string($idsArr)) { $this->where .= $idsArr; } return $this->where; }
public static function logDBUpdates($query_string, $db_name) { # Adds current query to update log $file_name = "../../local/log_" . $_SESSION['lab_config_id'] . "_updates.sql"; $file_name_revamp = "../../local/log_" . $_SESSION['lab_config_id'] . "_revamp_updates.sql"; $file_handle = null; $file_handle_revamp = null; if (file_exists($file_name)) { $file_handle = fopen($file_name, "a"); } else { $file_handle = fopen($file_name, "w"); fwrite($file_handle, "USE blis_" . $_SESSION['lab_config_id'] . ";\n\n"); } if (file_exists($file_name_revamp)) { $file_handle_revamp = fopen($file_name_revamp, "a"); } else { $file_handle_revamp = fopen($file_name_revamp, "w"); fwrite($file_handle_revamp, "USE blis_revamp;\n\n"); } $timestamp = date("Y-m-d H:i:s"); $log_line = $timestamp . "\t" . $query_string . "\n"; $pos = stripos($query_string, "SELECT"); if ($pos === false) { if ($db_name == "blis_revamp") { fwrite($file_handle_revamp, $log_line); } else { fwrite($file_handle, $log_line); } } fclose($file_handle); fclose($file_handle_revamp); }
public function submit($params, $radio) { //教务网登录 $this->login(); //获取评教参数 try { $http = new Http(array(CURLOPT_URL => $this->baseUrl . 'jxpjgl.do?' . $params, CURLOPT_COOKIE => $this->cookies, CURLOPT_TIMEOUT => 3)); } catch (\Exception $e) { throw new \Exception('网络异常,评教参数获取失败', Config::RETURN_ERROR); } $pattern = '/radioXh="0" value="(.*?)">(?:.*?)radioXh="1" value="(.*?)">(?:.*?)radioXh="2" value="(.*?)">(?:.*?)radioXh="3" value="(.*?)">/s'; preg_match_all($pattern, $http->content, $temp); if (count($temp[0]) != 10) { throw new \Exception('评教失败,请教参数有误', Config::RETURN_ERROR); } $mark = array($temp[1], $temp[2], $temp[3], $temp[4]); //构造get与post参数 $get = 'method=savePj&tjfs=2&val='; for ($i = 0; $i < 10; $i++) { $get .= urlencode($mark[$radio[$i]][$i]) . ($i == 9 ? '' : '*'); } parse_str($params, $temp); try { $http = new Http(array(CURLOPT_URL => $this->baseUrl . 'jxpjgl.do?' . $get, CURLOPT_POSTFIELDS => "type=2&pj09id=&pjdw=3&xsflid=&typejsxs=xs&pjfl=&pj01id={$temp['pj01id']}&pj05id={$temp['pj05id']}&jg0101id={$temp['jg0101id']}&jx0404id={$temp['jx0404id']}&pj0502id={$temp['pj0502id']}&jx02id={$temp['jx02id']}", CURLOPT_COOKIE => $this->cookies, CURLOPT_TIMEOUT => 3)); } catch (\Exception $e) { throw new \Exception('网络异常,评教提交失败', Config::RETURN_ERROR); } if (false === stripos($http->content, '提交成功!')) { throw new \Exception('未知错误,评教提交失败', Config::RETURN_ERROR); } return true; }