function cut($str, $limit, $more = " ...") { if ($str == "" || $str == NULL || is_array($str) || strlen($str) == 0) { return $str; } $str = trim($str); if (strlen($str) <= $limit) { return $str; } $str = substr($str, 0, $limit); if (!substr_count($str, " ")) { if ($more) { $str .= " ..."; } return $str; } while (strlen($str) && $str[strlen($str) - 1] != " ") { $str = substr($str, 0, -1); } $str = substr($str, 0, -1); if ($more) { $str .= " ..."; } return $str; }
public function testIntrospectionContainsOperationForEachPrototypeOfAPublicMethod() { $xml = $this->introspector->introspect('com.zend.framework.IntrospectorTest'); $this->assertEquals(4, substr_count($xml, 'name="foobar"')); $this->assertEquals(1, substr_count($xml, 'name="barbaz"')); $this->assertEquals(1, substr_count($xml, 'name="bazbat"')); }
/** * @group ZF-2062 * @group ZF-4190 */ public function testHtmlSpecialCharsInMessageGetEscapedForValidXml() { $f = new XmlFormatter(); $line = $f->format(array('message' => '&key1=value1&key2=value2', 'priority' => 42)); $this->assertContains("&", $line); $this->assertTrue(substr_count($line, "&") == 2); }
public static function processPassThrough($value) { // This function will parse the pass through data and populate and array with keys and values. // Passthrough format is key|value||key|value, etc. $passthrough_array = array(); $cursor_pos = 0; $single_bar_pos = 0; $double_bar_pos = 0; // Find out how many key|value sets there are $single_bar_count = substr_count($value, '|'); // loop passthrough data and add to array while ($cursor_pos < strlen($value)) { // position of the next single bar (end of key) $single_bar_pos = strpos($value, '|', $cursor_pos); // position of the next double bar (end of value) $double_bar_pos = strpos($value, '||', $cursor_pos); // at the end of the string the double bar will be absent and return false. // Then set the $double_bar_pos to the entire length of $value if ($double_bar_pos == false) { $double_bar_pos = strlen($value); } // set the key $array_key = substr($value, $cursor_pos, $single_bar_pos - $cursor_pos); // set the value $array_value = substr($value, $single_bar_pos + 1, $double_bar_pos - $single_bar_pos - 1); // move the cursor to the next key||value $cursor_pos = $double_bar_pos + 2; // add the key||value to the passthrough array $passthrough_array[$array_key] = $array_value; } // return the final passthrough array return $passthrough_array; }
function neat_r($arr, $return = false) { $out = array(); $oldtab = " "; $newtab = " "; $lines = explode("\n", print_r($arr, true)); foreach ($lines as $line) { if (substr($line, -5) != "Array") { $line = preg_replace("/^(\\s*)\\[[0-9]+\\] => /", "\$1", $line, 1); } foreach (array("Array" => "", "[" => "", "]" => "", " =>" => ":") as $old => $new) { $out = str_replace($old, $new, $out); } if (in_array(trim($line), array("Array", "(", ")", ""))) { continue; } $indent = "\n"; $indents = floor((substr_count($line, $oldtab) - 1) / 2); if ($indents > 0) { for ($i = 0; $i < $indents; $i++) { $indent .= $newtab; } } $out[] = $indent . trim($line); } $out = implode("<br/>", $out) . "\n"; if ($return == true) { return $out; } echo $out; }
function replace_var_generic($hardware_id, $url_group_server, $id_group = false) { $count_add_ip = substr_count($url_group_server, '$IP$'); $count_name = substr_count($url_group_server, '$NAME$'); if ($count_add_ip > 0 or $count_name > 0) { $sql = "select IPADDR,NAME,ID from hardware where ID"; if ($hardware_id != 'ALL') { $sql .= " = %s"; $arg = $hardware_id; } else { $sql .= " in (select hardware_id from groups_cache where group_id = %s)"; $arg = $id_group; } $resdefaultvalues = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); while ($item = mysql_fetch_object($resdefaultvalues)) { $url_temp = str_replace('$IP$', $item->IPADDR, $url_group_server); $url[$item->ID] = str_replace('$NAME$', $item->NAME, $url_temp); } } elseif ($hardware_id != 'ALL') { $url[$hardware_id] = $url_group_server; } else { $sql = "select ID from hardware where ID"; $sql .= " in (select hardware_id from groups_cache where group_id = %s)"; $arg = $id_group; $resdefaultvalues = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); while ($item = mysql_fetch_object($resdefaultvalues)) { $url[$item->ID] = $url_group_server; } } return $url; }
function writeBody($message, $stream, &$length_raw, $boundary = '') { if ($boundary && !$message->rfc822_header) { $s = '--' . $boundary . "\r\n"; $s .= $this->prepareMIME_Header($message, $boundary); $length_raw += strlen($s); if ($stream) { $this->preWriteToStream($s); $this->writeToStream($stream, $s); } } $this->writeBodyPart($message, $stream, $length_raw); $boundary_depth = substr_count($message->entity_id, '.'); if ($boundary_depth) { $boundary .= '_part' . $boundary_depth; } $last = false; for ($i = 0, $entCount = count($message->entities); $i < $entCount; $i++) { $msg = $this->writeBody($message->entities[$i], $stream, $length_raw, $boundary); if ($i == $entCount - 1) { $last = true; } } if ($boundary && $last) { $s = "--" . $boundary . "--\r\n\r\n"; $length_raw += strlen($s); if ($stream) { $this->preWriteToStream($s); $this->writeToStream($stream, $s); } } }
private function ParseHeaderFooter($str, $uid = null) { $str = preg_replace_callback('/%sort_?link:([a-z0-9_]+)%/i', array(__CLASS__, 'GenSortlink'), $str); if (strpos($str, '%search_form%') !== false) { wpfb_loadclass('Output'); $str = str_replace('%search_form%', WPFB_Output::GetSearchForm("", $_GET), $str); } $str = preg_replace_callback('/%print_?(script|style):([a-z0-9_-]+)%/i', array(__CLASS__, 'PrintScriptCallback'), $str); if (empty($uid)) { $uid = uniqid(); } $str = str_replace('%uid%', $uid, $str); $count = 0; $str = preg_replace("/jQuery\\((.+?)\\)\\.dataTable\\s*\\((.*?)\\)(\\.?.*?)\\s*;/", 'jQuery($1).dataTable((function(options){/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/})($2))$3;', $str, -1, $count); if ($count > 0) { $dataTableOptions = array(); list($sort_field, $sort_dir) = wpfb_call('Output', 'ParseSorting', $this->current_list->file_order); $file_tpl = WPFB_Core::GetTpls('file', $this->file_tpl_tag); if (($p = strpos($file_tpl, "%{$sort_field}%")) > 0) { // get the column index of field to sort $col_index = substr_count($file_tpl, "</t", 0, $p); $dataTableOptions["aaSorting"] = array(array($col_index, strtolower($sort_dir))); } if ($this->current_list->page_limit > 0) { $dataTableOptions["iDisplayLength"] = $this->current_list->page_limit; } $str = str_replace('/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/', " var wpfbOptions = " . json_encode($dataTableOptions) . "; " . " if('object' == typeof(options)) { for (var v in options) { wpfbOptions[v] = options[v]; } }" . " return wpfbOptions; ", $str); } return $str; }
/** * Checks if the ip is v4. * * @param string $ip IP to check * * @return bool return true if ipv4 */ public static function isIpv4($requestIp) { if (substr_count($requestIp, ':') > 1) { return false; } return true; }
public static function addAdminScript() { $checkJqueryLoaded = false; $document = JFactory::getDocument(); $header = $document->getHeadData(); JHTML::_('behavior.framework'); if (!version_compare(JVERSION, '3.0', 'ge')) { foreach ($header['scripts'] as $scriptName => $scriptData) { if (substr_count($scriptName, '/jquery')) { $checkJqueryLoaded = true; } } //Add js if (!$checkJqueryLoaded) { $document->addScript(JURI::root() . 'components/com_bt_socialconnect/assets/js/jquery.min.js'); } } $document->addScript(JURI::root() . 'components/com_bt_socialconnect/assets/js/default.js'); $document->addScript(JURI::root() . 'components/com_bt_socialconnect/assets/js/menu.js'); $document->addScript(JURI::root() . 'administrator/components/com_bt_socialconnect/assets/js/bt_social.js'); $document->addScriptDeclaration('jQuery.noConflict();'); $document->addStyleSheet(JURI::root() . 'components/com_bt_socialconnect/assets/icon/admin.css'); $document->addStyleSheet(JURI::root() . 'components/com_bt_socialconnect/assets/css/legacy.css'); $document->addStyleSheet(JURI::root() . 'administrator/components/com_bt_socialconnect/assets/css/bt_social.css'); if (!Bt_SocialconnectLegacyHelper::isLegacy()) { JHtml::_('formbehavior.chosen', 'select'); } }
function construct_ip_register_table($ipaddress, $prevuserid, $depth = 1) { global $vbulletin, $vbphrase; $depth--; if (VB_AREA == 'AdminCP') { $userscript = 'usertools.php'; } else { $userscript = 'user.php'; } if (substr($ipaddress, -1) == '.' or substr_count($ipaddress, '.') < 3) { // ends in a dot OR less than 3 dots in IP -> partial search $ipaddress_match = "ipaddress LIKE '" . $vbulletin->db->escape_string_like($ipaddress) . "%'"; } else { // exact match $ipaddress_match = "ipaddress = '" . $vbulletin->db->escape_string($ipaddress) . "'"; } $users = $vbulletin->db->query_read_slave("\n\t\tSELECT userid, username, ipaddress\n\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\tWHERE {$ipaddress_match} AND\n\t\t\tipaddress <> '' AND\n\t\t\tuserid <> {$prevuserid}\n\t\tORDER BY username\n\t"); $retdata = ''; while ($user = $vbulletin->db->fetch_array($users)) { $retdata .= '<li>' . "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=" . iif(VB_AREA == 'ModCP', 'viewuser', 'edit') . "&u={$user['userid']}\"><b>{$user['username']}</b></a> \n\t\t\t<a href=\"{$userscript}?" . $vbulletin->session->vars['sessionurl'] . "do=gethost&ip={$user['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$user['ipaddress']}</a> " . construct_link_code($vbphrase['find_posts_by_user'], "../search.php?" . $vbulletin->session->vars['sessionurl'] . "do=finduser&u={$user['userid']}", '_blank') . construct_link_code($vbphrase['view_other_ip_addresses_for_this_user'], "{$userscript}?" . $vbulletin->session->vars['sessionurl'] . "do=doips&u={$user['userid']}&hash=" . CP_SESSIONHASH) . "</li>\n"; if ($depth > 0) { $retdata .= construct_user_ip_table($user['userid'], $user['ipaddress'], $depth); } } if (empty($retdata)) { return ''; } else { return '<ul>' . $retdata . '</ul>'; } }
function validation($data, $files) { $errors = parent::validation($data, $files); // TODO - this reg expr can be improved if (!preg_match("/(\\(*\\s*\\bc\\d{1,2}\\b\\s*\\(*\\)*\\s*(\\(|and|or)\\s*)+\\(*\\s*\\bc\\d{1,2}\\b\\s*\\(*\\)*\\s*\$/i", $data['conditionexpr'])) { $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports'); } if (substr_count($data['conditionexpr'], '(') != substr_count($data['conditionexpr'], ')')) { $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports'); } if (isset($this->_customdata['elements']) && is_array($this->_customdata['elements'])) { $elements = $this->_customdata['elements']; $nel = count($elements); if (!empty($elements) && $nel > 1) { preg_match_all('/(\\d+)/', $data['conditionexpr'], $matches, PREG_PATTERN_ORDER); foreach ($matches[0] as $num) { if ($num > $nel) { $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports'); break; } } } } return $errors; }
protected function match_variable($src) { $hash = []; while (preg_match("/({(\\\$[\$\\w][^\t]*)})/s", $src, $vars, PREG_OFFSET_CAPTURE)) { list($value, $pos) = $vars[1]; if ($value == '') { break; } if (substr_count($value, '}') > 1) { for ($i = 0, $start = 0, $end = 0; $i < strlen($value); $i++) { if ($value[$i] == '{') { $start++; } else { if ($value[$i] == '}') { if ($start == ++$end) { $value = substr($value, 0, $i + 1); break; } } } } } $length = strlen($value); $src = substr($src, $pos + $length); $hash[sprintf('%03d_%s', $length, $value)] = $value; } krsort($hash, SORT_STRING); return $hash; }
public function parse_header($header) { $last_header = ''; $parsed_header = array(); for ($j = 0, $end = sizeof($header); $j < $end; $j++) { $hd = split(':', $header[$j], 2); if (preg_match_all("/\s/", $hd[0], $matches) || !isset($hd[1]) || !$hd[1]) { if ($last_header) { $parsed_header[$last_header] .= "\r\n" . trim($header[$j]); } } else { $last_header = strtolower($hd[0]); if (!isset($parsed_header[$last_header])) { $parsed_header[$last_header] = ''; } $parsed_header[$last_header] .= (($parsed_header[$last_header]) ? "\r\n" : '') . trim($hd[1]); } } foreach ($parsed_header as $hd_name => $hd_content) { $start_enc_tag = $stop_enc_tag = 0; $pre_text = $enc_text = $post_text = ""; while(1) { if (strstr($hd_content, '=?') && strstr($hd_content, '?=') && substr_count($hd_content,'?') > 3) { $start_enc_tag = strpos($hd_content, '=?'); $pre_text = substr($hd_content, 0, $start_enc_tag); do { $stop_enc_tag = strpos($hd_content, '?=', $stop_enc_tag) + 2; $enc_text = substr($hd_content, $start_enc_tag, $stop_enc_tag); } while (!(substr_count($enc_text, '?') > 3)); $enc_text = explode('?', $enc_text, 5); switch (strtoupper($enc_text[2])) { case "B": $dec_text = base64_decode($enc_text[3]); break; case "Q": default: $dec_text = quoted_printable_decode($enc_text[3]); $dec_text = str_replace('_', ' ', $dec_text); break; } $post_text = substr($hd_content, $stop_enc_tag); if (substr(ltrim($post_text), 0, 2) == '=?') { $post_text = ltrim($post_text); } $hd_content = $pre_text . $dec_text . $post_text; $parsed_header[$hd_name] = $hd_content; } else { break; } } } return $parsed_header; }
function link_library_modify_http_response($plugins_response) { foreach ($plugins_response as $response_key => $plugin_response) { if (plugin_basename(__FILE__) == $plugin_response->plugin) { if (3 <= substr_count($plugin_response->new_version, '.')) { $plugin_info = get_plugin_data(__FILE__); $period_position = link_library_strposX($plugin_info['Version'], '.', 3); if (false !== $period_position) { $current_version = substr($plugin_info['Version'], 0, $period_position); } else { $current_version = $plugin_info['Version']; } $period_position2 = link_library_strposX($plugin_response->new_version, '.', 3); if (false !== $period_position) { $new_version = substr($plugin_response->new_version, 0, $period_position2); } else { $new_version = $plugin_response->new_version; } $version_diff = version_compare($current_version, $new_version); if (-1 < $version_diff) { unset($plugins_response->{$response_key}); } } } } return $plugins_response; }
/** * function to get multilanguage strings * * This is actually a wrapper for ATK's atktext() method, for * use in templates. * * @author Ivo Jansch <*****@*****.**> * * Example: {atktext id="users.userinfo.description"} * {atktext id="userinfo.description" module="users"} * {atktext id="description" module="users" node="userinfo"} * */ function smarty_function_atktext($params, &$smarty) { if (!isset($params["id"])) { $params["id"] = $params[0]; } switch (substr_count($params["id"], ".")) { case 1: list($module, $id) = explode(".", $params["id"]); $str = atktext($id, $module, isset($params["node"]) ? $params["node"] : ''); break; case 2: list($module, $node, $id) = explode(".", $params["id"]); $str = atktext($id, $module, $node); break; default: $str = atktext($params["id"], atkArrayNvl($params, "module", ""), atkArrayNvl($params, "node", ""), atkArrayNvl($params, "lng", "")); } if (isset($params["filter"])) { $fn = $params["filter"]; $str = $fn($str); } // parse the rest of the params in the string atkimport("atk.utils.atkstringparser"); $parser = new atkStringParser($str); return $parser->parse($params); }
/** * Set value of an item. * * @param string $path system.common.global.sn or system.common.sn * @param string $value * @param null|string $lang * @access public * @return void */ public function setItem($path, $value = '', $lang = null) { $level = substr_count($path, '.'); $section = ''; if ($level <= 1) { return false; } if ($level == 2) { list($owner, $module, $key) = explode('.', $path); } if ($level == 3) { list($owner, $module, $section, $key) = explode('.', $path); } $item = new stdclass(); $item->owner = $owner; $item->module = $module; $item->section = $section; $item->key = $key; $item->value = $value; $clientLang = $this->app->getClientLang(); $defaultLang = !empty($clientLang) ? $clientLang : 'zh-cn'; $item->lang = $lang ? $lang : $defaultLang; $this->dao->replace(TABLE_CONFIG)->data($item)->exec(); return !dao::isError(); }
public static function getContentList($params) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); //$matchtype = $params->get('matchtype', 'all'); $maximum = $params->get('maximum', 5); $tagsHelper = new JHelperTags(); $option = $app->input->get('option'); $view = $app->input->get('view'); $prefix = $option . '.' . $view; $id = (array) $app->input->getObject('id'); $selectedTag = $params->get('selected_tag'); // Strip off any slug data. foreach ($id as $id) { if (substr_count($id, ':') > 0) { $idexplode = explode(':', $id); $id = $idexplode[0]; } } $tagsToMatch = $selectedTag; if (!$tagsToMatch || is_null($tagsToMatch)) { return $results = false; } $query = $tagsHelper->getTagItemsQuery($tagsToMatch, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC', $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1'); $db->setQuery($query, 0, $maximum); $results = $db->loadObjectList(); foreach ($results as $result) { $explodedAlias = explode('.', $result->type_alias); $result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias; } return $results; }
public static function decode($input) { if (empty($input)) { return; } $paddingCharCount = substr_count($input, self::$map[32]); $allowedValues = array(6, 4, 3, 1, 0); if (!in_array($paddingCharCount, $allowedValues)) { return false; } for ($i = 0; $i < 4; $i++) { if ($paddingCharCount == $allowedValues[$i] && substr($input, -$allowedValues[$i]) != str_repeat(self::$map[32], $allowedValues[$i])) { return false; } } $input = str_replace('=', '', $input); $input = str_split($input); $binaryString = ""; for ($i = 0; $i < count($input); $i = $i + 8) { $x = ""; if (!in_array($input[$i], self::$map)) { return false; } for ($j = 0; $j < 8; $j++) { $x .= str_pad(base_convert(@self::$flippedMap[@$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); } $eightBits = str_split($x, 8); for ($z = 0; $z < count($eightBits); $z++) { $binaryString .= ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ? $y : ""; } } return $binaryString; }
function extract_columns(&$columns, $file, $length) { $fp = fopen($file, 'r'); $index = 0; $z = 0; $mu = 0; $dmu = 0; while ($cols = fgetcsv($fp, 1024, ",")) { if (empty($cols[0])) { continue; } $pm_count = substr_count($cols[0], "±"); if ($pm_count > 1) { $index += $pm_count - 1; $cols[0] = trim(skip($cols[0], " ", 4 * ($pm_count - 1))); echo $cols[0] . "\n"; } if ($index == 1) { $z = $cols[0]; } if ($index == 6) { $mu = (double) $cols[0]; $dmu = trim(substr($cols[0], strpos($cols[0], "±") + 2)); } if ($index >= $length - 1) { $index = 0; $columns[] = array($z, $mu, $dmu); } else { ++$index; } } }
function search_doc_files($s) { $a = get_app(); $itemspage = get_pconfig(local_channel(), 'system', 'itemspage'); App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); $regexop = db_getfunc('REGEXP'); $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC)); $r = fetch_post_tags($r, true); for ($x = 0; $x < count($r); $x++) { $r[$x]['text'] = $r[$x]['body']; $r[$x]['rank'] = 0; if ($r[$x]['term']) { foreach ($r[$x]['term'] as $t) { if (stristr($t['term'], $s)) { $r[$x]['rank']++; } } } if (stristr($r[$x]['sid'], $s)) { $r[$x]['rank']++; } $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s)); // bias the results to the observer's native language if ($r[$x]['lang'] === App::$language) { $r[$x]['rank'] = $r[$x]['rank'] + 10; } } usort($r, 'doc_rank_sort'); return $r; }
/** * Returns the next token id. * * @param mixed $value Variable to store token content in * @param mixed $line Variable to store line in * @param mixed $docComment Variable to store doc comment in * * @return int Token id */ public function lex(&$value = null, &$line = null, &$docComment = null) { $docComment = null; while (isset($this->tokens[++$this->pos])) { $token = $this->tokens[$this->pos]; if (is_string($token)) { $line = $this->line; // bug in token_get_all if ('b"' === $token) { $value = 'b"'; return ord('"'); } else { $value = $token; return ord($token); } } else { $this->line += substr_count($token[1], "\n"); if (T_DOC_COMMENT === $token[0]) { $docComment = $token[1]; } elseif (!isset(self::$dropTokens[$token[0]])) { $value = $token[1]; $line = $token[2]; return self::$tokenMap[$token[0]]; } } } return 0; }
/** * @param integer $errno * @param string $errstr * @param string $errfile * @param integer $errline * @return bool */ public static function loadXmlErrorHandler($errno, $errstr, $errfile, $errline) { if (substr_count($errstr, 'DOMDocument::loadXML()') > 0) { return true; } return false; }
protected function createController($controller) { if (false === ($pos = strpos($controller, '::'))) { $count = substr_count($controller, ':'); if (2 == $count) { // controller in the a:b:c notation then $controller = $this->parser->parse($controller); $pos = strpos($controller, '::'); } elseif (1 == $count) { // controller in the service:method notation list($service, $method) = explode(':', $controller); return array($this->container->get($service), $method); } else { throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller)); } } $class = substr($controller, 0, $pos); $method = substr($controller, $pos + 2); if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); } $controller = call_user_func($this->createInjector($class), $this->container); if ($controller instanceof ContainerAwareInterface) { $controller->setContainer($this->container); } return array($controller, $method); }
function built_group_nav_sub($group_id, $group_nav = '') { global $ttH; //update project $col_up = array(); $col_up["group_nav"] = $group_nav; $ttH->db->do_update("project", $col_up, " group_id='" . $group_id . "'"); //End $query = "select group_id \r\r\n\t\t\t\t\t\tfrom project_group \r\r\n\t\t\t\t\t\twhere parent_id='" . $group_id . "' "; //echo $query; $result = $ttH->db->query($query); while ($row = $ttH->db->fetch_row($result)) { $col = array(); $col["group_nav"] = $group_nav; $col["group_nav"] .= !empty($col["group_nav"]) ? ',' : ''; $col["group_nav"] .= $row['group_id']; $col["group_level"] = substr_count($col['group_nav'], ',') + 1; $ok = $ttH->db->do_update("project_group", $col, " group_id='" . $row['group_id'] . "'"); if ($ok) { //update project $col_up = array(); $col_up["group_nav"] = $col["group_nav"]; $ttH->db->do_update("project", $col_up, " group_id='" . $row['group_id'] . "'"); //End built_group_nav_sub($row['group_id'], $col["group_nav"]); } } return ''; }
public function replaceFile($file, $newpath) { $done = false; $conf_file = $this->folder() . '/config.mlt'; $mlt = file_get_contents($conf_file); /* The "original_path" of files is always saved as absolute, but in the mlt file they may appear as relative to a given root. In this way we look for the effective path in the file. Note that all occurrences of the path are substituted: eventual duplicated references are already tracked in the parsing phase (cfr. TestJob) */ $path = $file->original_path; $path_arr = $this->tokenizePath($path); $references = 0; while (count($path_arr) != 0 && $references != $file->references) { if (strpos($mlt, $path) != false) { $references += substr_count($mlt, $path); $mlt = str_replace($path, $newpath, $mlt); } array_shift($path_arr); $path = join('/', $path_arr); } if ($references == $file->references) { file_put_contents($conf_file, $mlt); } }
public function testSanitizeNotificationSection() { $notifications = TestDataService::loadObjectList('BeaconNotification', $this->fixture, 'BeaconNotification'); $notificationXML = new SimpleXMLElement($notifications[0]->getDefinition()); $sanitizedBody = $this->beaconNotificationService->sanitizeNotificationSection($notificationXML->content->body . ""); $this->assertTrue(substr_count($sanitizedBody, '<script>') == 0); }
public static function newFromString($string, $default = null) { $matches = null; $ok = preg_match('/^([-$]*(?:\\d+)?(?:[.]\\d{0,2})?)(?:\\s+([A-Z]+))?$/', trim($string), $matches); if (!$ok) { self::throwFormatException($string); } $value = $matches[1]; if (substr_count($value, '-') > 1) { self::throwFormatException($string); } if (substr_count($value, '$') > 1) { self::throwFormatException($string); } $value = str_replace('$', '', $value); $value = (double) $value; $value = (int) round(100 * $value); $currency = idx($matches, 2, $default); switch ($currency) { case 'USD': break; default: throw new Exception(pht("Unsupported currency '%s'!", $currency)); } return self::newFromValueAndCurrency($value, $currency); }
protected function getInput() { JHTML::_('behavior.framework'); $document =& JFactory::getDocument(); if (!version_compare(JVERSION, '3.0', 'ge')) { $checkJqueryLoaded = false; $header = $document->getHeadData(); foreach ($header['scripts'] as $scriptName => $scriptData) { if (substr_count($scriptName, '/jquery')) { $checkJqueryLoaded = true; } } //Add js if (!$checkJqueryLoaded) { $document->addScript(JURI::root() . $this->element['path'] . 'js/jquery.min.js'); } $document->addScript(JURI::root() . $this->element['path'] . 'js/chosen.jquery.min.js'); $document->addStyleSheet(JURI::root() . $this->element['path'] . 'css/chosen.css'); } $document->addScript(JURI::root() . $this->element['path'] . 'js/colorpicker/colorpicker.js'); $document->addScript(JURI::root() . $this->element['path'] . 'js/jquery.lightbox-0.5.min.js'); $document->addScript(JURI::root() . $this->element['path'] . 'js/btbase64.min.js'); $document->addScript(JURI::root() . $this->element['path'] . 'js/bt.js'); $document->addScript(JURI::root() . $this->element['path'] . 'js/script.js'); //Add css $document->addStyleSheet(JURI::root() . $this->element['path'] . 'css/bt.css'); $document->addStyleSheet(JURI::root() . $this->element['path'] . 'js/colorpicker/colorpicker.css'); $document->addStyleSheet(JURI::root() . $this->element['path'] . 'css/jquery.lightbox-0.5.css'); return null; }
function buildGallery($resName, $typeFolder) { $all = implode(scandir(get_template_directory() . "/images/photos/" . $resName . "/" . $typeFolder, 1)); $count = substr_count($all, 'tiny'); for ($a = 1; $a <= $count; $a++) { ?> <a href="<?php echo get_template_directory_uri(); ?> /images/photos/<?php echo $resName; ?> /<?php echo $typeFolder; ?> /<?php echo $a; ?> -full.jpg" class="thumb col-xs-6 col-sm-4 col-md-3 col-lg-3"> <img src="<?php echo get_template_directory_uri(); ?> /images/photos/<?php echo $resName; ?> /<?php echo $typeFolder; ?> /<?php echo $a; ?> -xsmall.jpg"></a> <?php } }