public function render() { $uri = $_SERVER['REQUEST_URI']; $temp = mb_str_replace("-", " ", substr($uri, strrpos($uri, "/") + 1)); switch (mb_strtolower($temp)) { case "wildernessone": $ViewData['search'] = "WildernessOne"; break; case "geotrak": $ViewData['search'] = "GeoTrak"; break; case "oceanx": $ViewData['search'] = "OceanX"; break; } $ViewData['title'] = "Shop | Peak Outdoor Adventure"; $ViewData['copyright'] = date("Y"); $ViewData['stylesheets'] = ["index", "shop"]; $ViewData['javascript'] = ["jquery", "shop"]; $products = json_decode(file_get_contents(__DIR__ . "\\..\\..\\Data\\products.json")); foreach ($products as $product) { if (mb_strtolower($product->collection) === mb_strtolower($ViewData['search'])) { $ViewData['products'][] = $product; } } foreach ($products as $product) { $ViewData['categories'][] = $product->category; } $ViewData['categories'] = array_unique($ViewData['categories']); foreach ($products as $product) { $ViewData['collections'][] = $product->collection; } $ViewData['collections'] = array_unique($ViewData['collections']); echo $this->razr->render('Templates\\Shop\\index.razr.php', $ViewData); }
/** * Smarty replace modifier plugin * * Type: modifier<br> * Name: replace<br> * Purpose: simple search/replace * * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @author Uwe Tews * @param string $ * @param string $ * @param string $ * @return string */ function smarty_modifier_replace($string, $search, $replace) { if (!function_exists('mb_str_replace')) { // simulate the missing PHP mb_str_replace function function mb_str_replace($needles, $replacements, $haystack) { $rep = (array) $replacements; foreach ((array) $needles as $key => $needle) { $replacement = $rep[$key]; $needle_len = mb_strlen($needle); $replacement_len = mb_strlen($replacement); $pos = mb_strpos($haystack, $needle, 0); while ($pos !== false) { $haystack = mb_substr($haystack, 0, $pos) . $replacement . mb_substr($haystack, $pos + $needle_len); $pos = mb_strpos($haystack, $needle, $pos + $replacement_len); } } return $haystack; } } if (function_exists('mb_substr')) { return mb_str_replace($search, $replace, $string); } else { return str_replace($search, $replace, $string); } }
/** * マルチバイト対応 str_replace() * * @param mixed $search 検索文字列(またはその配列) * @param mixed $replace 置換文字列(またはその配列) * @param mixed $subject 対象文字列(またはその配列) * @param string $encoding 文字列のエンコーディング(省略: 内部エンコーディング) * @return mixed subject 内の search を replace で置き換えた文字列 * * この関数の $search, $replace, $subject は配列に対応していますが、 * $search, $replace が配列の場合の挙動が PHP 標準の str_replace() と異なります。 */ function mb_str_replace($search, $replace, $subject, $encoding = 'auto') { if (!is_array($search)) { $search = array($search); } if (!is_array($replace)) { // PHP manual: // search が配列で replace が文字列の場合、 // この置換文字列が search の各値について使用されます。 // // array_fill_keysは5.2以上なので使えない... $replace = array_combine(array_keys($search), array_fill(0, count($search), $replace)); } if (strtolower($encoding) === 'auto') { $encoding = mb_internal_encoding(); } // $subject が複数ならば各要素に繰り返し適用する if (is_array($subject) || $subject instanceof Traversable) { $result = array(); foreach ($subject as $key => $val) { $result[$key] = mb_str_replace($search, $replace, $val, $encoding); } return $result; } $currentpos = 0; // 現在の検索開始位置 while (true) { // $currentpos 以降で $search のいずれかが現れる位置を検索する $index = -1; // 見つけた文字列(最も前にあるもの)の $search の index $minpos = -1; // 見つけた文字列(最も前にあるもの)の位置 foreach ($search as $key => $find) { if ($find == '') { continue; } $findpos = mb_strpos($subject, $find, $currentpos, $encoding); if ($findpos !== false) { if ($minpos < 0 || $findpos < $minpos) { $minpos = $findpos; $index = $key; } } } // $search のいずれも見つからなければ終了 if ($minpos < 0) { break; } // 置換実行 $replaced = array_key_exists($index, $replace) ? $replace[$index] : ''; $subject = mb_substr($subject, 0, $minpos, $encoding) . $replaced . mb_substr($subject, $minpos + mb_strlen($search[$index], $encoding), mb_strlen($subject, $encoding), $encoding); // 「現在位置」を $r の直後に設定 $currentpos = $minpos + mb_strlen($replaced, $encoding); } return $subject; }
protected function formatRow(array $row) { $ret = array_map(function ($cell) { $cell = mb_convert_encoding((string) $cell, $this->outputCharset, $this->inputCharset); if (!preg_match('/[",\\x0d\\x0a]/', $cell)) { return $cell; } return '"' . mb_str_replace('"', '""', $cell, $this->outputCharset) . '"'; }, $row); return implode(',', $ret); }
public static function replace($haystack, $needle, $replace, $regex = false) { if ($regex) { $r = preg_replace($needle, $replace, $haystack); } else { if (String::$multibyte) { $r = mb_str_replace($needle, $replace, $haystack); } else { $r = str_replace($needle, $replace, $haystack); } } return new String($r); }
public function AddExtraHTMLToSidebar(&$company) { define('API', 'PS'); require_once 'siteadmin/includes/config/affiliatewindow.php'; $result = CPHelper::getStaggImageHTML($company['staggurl']); $result .= '<div id="sidebar-merchantDescription-main"><h3>' . (empty($company['sidebar_title']) ? 'Quick Glance' : $company['sidebar_title']) . '</h3>'; $result .= mb_str_replace('{logo}', '<img src="' . $company['logourl'] . '" style="float:left; margin:5px;"/>', $company['sidebar']); if (!empty($company['displayurl'])) { list($cloakedURL, $realURL) = CPHelper::getCompanyURLs($company['id'], $company['displayurl'], $company['source']); $result .= '<ul><li class="official-website"><h4>Official Website</h4><a href="' . $cloakedURL . '" target="_blank">' . $realURL . '</a></li></ul>'; } $result .= '</div>'; $company['sidebar'] = $result; }
function arabicToPersian($inp) { $out = str_replace("ي", "ی", $inp); $out = str_replace("ك", "ک", $out); $out = $out == 'امام خمینی' ? 'تهران' : $out; $out = mb_str_replace(array("ـ", " "), "", $out); if ($out == 'خرمآباد' || $out == 'خرماباد') { $out = 'خرمآباد'; } switch ($out) { case 'Tehran': $out = 'تهران'; break; } return $out; }
/** * Prueft die URL damit keine boesen URLS uebergeben werden koennen * @param $param */ function validURLCheck($param) { if (strstr($param, '://')) { // Der APP_ROOT muss in der URL vorkommen, sonfern es kein relativer Pfad ist // HTTPS und HTTP if (mb_strpos($param, APP_ROOT) !== 0 && mb_strpos(mb_str_replace("http://", "https://", $param), APP_ROOT) !== 0 && mb_strpos(mb_str_replace("https://", "http://", $param), APP_ROOT) !== 0) { $text = "Dies ist eine automatische Mail.\nEs wurde eine mögliche XSS Attacke durchgefuehrt:\n"; $text .= "\nFolgende URL wurde versucht aufzurufen: \n" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $text .= "\n\nIP des Aufrufers: " . $_SERVER['REMOTE_ADDR']; $text .= "\n\nUserAgent: " . $_SERVER['HTTP_USER_AGENT']; $text .= "\n\nAuffälliger Value: {$param}"; $mail = new mail(MAIL_ADMIN, 'no-reply@' . DOMAIN, 'Versuchte XSS Attacke', $text); $mail->send(); die('Invalid URL detected'); } } }
public function render() { $uri = $_SERVER['REQUEST_URI']; $id = mb_str_replace("-", " ", substr($uri, strrpos($uri, "/") + 1)); $ViewData['title'] = "Product Details | Peak Outdoor Adventure"; $ViewData['copyright'] = date("Y"); $ViewData['stylesheets'] = ["details"]; $ViewData['javascript'] = ["jquery", "details"]; $products = json_decode(file_get_contents(__DIR__ . "\\..\\..\\Data\\products.json")); foreach ($products as $product) { if ($product->id === intval($id, 10)) { $ViewData['product'] = $product; break; } } echo $this->razr->render('Templates\\Shop\\details.razr.php', $ViewData); }
/** * Text mb_replace() functionality * * @dataProvider getReplaceStringProvider * @var mixed $search * @var mixed $replace * @var string $subject * @var string $expectedResult * @var int $expectedCount * @return void */ public function testMbStrReplace($search, $replace, $subject, $expectedResult, $expectedCount) { //echo $url . "\n"; try { self::startTimer('mb_str_replace', microtime(true)); $result = mb_str_replace($search, $replace, $subject, $count); self::endTimer('mb_str_replace', microtime(true)); $this->assertSame($expectedResult, $result, "Mismatch in result"); $this->assertSame($expectedCount, $count, "Mismatch in count"); } catch (Exception $e) { echo "Exception " . $e->getMessage() . " on subject: '{$subject}'\n"; var_dump($search); var_dump($replace); // rethrow it throw $e; } }
private function mb_str_replace($search, $replace, $subject, &$count = 0) { if (!is_array($subject)) { $searches = is_array($search) ? array_values($search) : array($search); $replacements = is_array($replace) ? array_values($replace) : array($replace); $replacements = array_pad($replacements, count($searches), ''); foreach ($searches as $key => $search) { $parts = mb_split(preg_quote($search), $subject); $count += count($parts) - 1; $subject = implode($replacements[$key], $parts); } } else { foreach ($subject as $key => $value) { $subject[$key] = mb_str_replace($search, $replace, $value, $count); } } return $subject; }
/** * Replaces a smarty block with an other one. * If the PHP multibyte (mb) extension is installed this * function is multibyte char aware * * The first parameter has one 'search' and one 'replace' key * * @param array $params * @param string $content * @param mixed $smarty * @param int $repeat * @param string $template * @return string */ function smarty_block_replace($params, $content, $smarty, &$repeat, $template) { if (is_null($content)) { return; } if (empty($params['search'])) { return $content; } if (empty($params['replace'])) { $params['replace'] = ''; } if (function_exists('mb_substr')) { require_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; return mb_str_replace($params['search'], $params['replace'], $content); } else { return str_replace($params['search'], $params['replace'], $content); } }
private function normalize_uri($uri) { // Remove query string if any if (FALSE !== strpos($uri, "?")) { echo $uri = substr($uri, 0, strpos($uri, "?")); } // Trim leading and trailing slashes $uri = trim($uri, "/"); // Escape slashes for RegEx $uri = mb_str_replace("/", "\\/", $uri); // Escape actual dots $uri = mb_str_replace(".", "\\.", $uri); // Swap (:num) expression $uri = mb_str_replace("(:num)", "[0-9]+", $uri); // Swap (:alpha) expression $uri = mb_str_replace("(:alpha)", "[A-Za-z]+", $uri); $uri = "/^" . $uri . "\$/"; return $uri; }
function mb_str_replace($search, $replace, $subject, $encoding = 'auto') { if (!is_array($search)) { $search = array($search); } if (!is_array($replace)) { $replace = array($replace); } if (strtolower($encoding) === 'auto') { $encoding = mb_internal_encoding(); } if (is_array($subject)) { $result = array(); foreach ($subject as $key => $val) { $result[$key] = mb_str_replace($search, $replace, $val, $encoding); } return $result; } $currentpos = 0; while (true) { $index = $minpos = -1; foreach ($search as $key => $find) { if ($find == '') { continue; } $findpos = mb_strpos($subject, $find, $currentpos, $encoding); if ($findpos !== false) { if ($minpos < 0 || $findpos < $minpos) { $minpos = $findpos; $index = $key; } } } if ($minpos < 0) { break; } $r = array_key_exists($index, $replace) ? $replace[$index] : ''; $subject = sprintf('%s%s%s', mb_substr($subject, 0, $minpos, $encoding), $r, mb_substr($subject, $minpos + mb_strlen($search[$index], $encoding), mb_strlen($subject, $encoding), $encoding)); $currentpos = $minpos + mb_strlen($r, $encoding); } return $subject; }
function mb_str_replace($search, $replace, $subject, &$count = 0) { if (!is_array($subject)) { // Normalize $search and $replace so they are both arrays of the same length $searches = is_array($search) ? array_values($search) : array($search); $replacements = is_array($replace) ? array_values($replace) : array($replace); $replacements = array_pad($replacements, count($searches), ''); foreach ($searches as $key => $search) { $parts = mb_split(preg_quote($search), $subject); $count += count($parts) - 1; $subject = implode($replacements[$key], $parts); } } else { // Call mb_str_replace for each subject in array, recursively foreach ($subject as $key => $value) { $subject[$key] = mb_str_replace($search, $replace, $value, $count); } } return $subject; }
function smarty_function_lang($params, $smarty) { if (!isset($params['code'])) { throw new rad_exception("lang: missing 'code' parameter", E_USER_WARNING); } $params['code'] = trim($params['code'], " \t\"'"); if (isset($params['lang'])) { $val = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array($params['code'], $params['lang'])); } else { $val = call_user_func_array(array(rad_config::getParam('loader_class'), 'lang'), array($params['code'])); } if (isset($params['find']) && isset($params['replace'])) { if (!is_array($params['find'])) { $params['find'] = array($params['find']); } if (!is_array($params['replace'])) { $params['replace'] = array($params['replace']); } if (count($params['find']) != count($params['replace'])) { throw new rad_exception('lang: find/replace params should either be both scalar or be arrays of the same size'); } $find = reset($params['find']); $replace = reset($params['replace']); while ($find) { $val = mb_str_replace($val, $find, $replace); $find = next($params['find']); $replace = next($params['replace']); } } if (!empty($params['htmlchars'])) { $val = mb_str_replace($val, '"', '"'); } if (!empty($params['ucf'])) { $val = mb_ucfirst($val); } if (isset($params['assign'])) { $smarty->assign($params['assign'], $val); } else { return $val; } }
public function mb_str_replace($search, $replace, $subject) { if (is_array($subject)) { foreach ($subject as $key => $val) { $subject[$key] = mb_str_replace((string) $search, $replace, $subject[$key]); } return $subject; } $pattern = '/(?:' . implode('|', array_map(create_function('$match', 'return preg_quote($match[0], "/");'), (array) $search)) . ')/u'; if (is_array($search)) { if (is_array($replace)) { $len = min(count($search), count($replace)); $table = array_combine(array_slice($search, 0, $len), array_slice($replace, 0, $len)); $f = create_function('$match', '$table = ' . var_export($table, true) . '; return array_key_exists($match[0], $table) ? $table[$match[0]] : $match[0];'); $subject = preg_replace_callback($pattern, $f, $subject); return $subject; } } $subject = preg_replace($pattern, (string) $replace, $subject); return $subject; }
/** * mb_str_replace() * Alternative mb_str_replace in case mb_string is not available * (array aware from here http://www.php.net/manual/en/ref.mbstring.php) * * @param mixed $search : string or array of strings to be searched. * @param mixed $replace : string or array of the strings that will replace the searched string(s) * @param mixed $subject : string to be modified. * @return string with the replacements made */ function mb_str_replace($search, $replace, $subject) { if (is_array($subject)) { $ret = array(); foreach ($subject as $key => $val) { $ret[$key] = mb_str_replace($search, $replace, $val); } return $ret; } foreach ((array) $search as $key => $s) { if ($s == '') { continue; } $r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : ''); $pos = mb_strpos($subject, $s); while ($pos !== false) { $subject = mb_substr($subject, 0, $pos) . $r . mb_substr($subject, $pos + mb_strlen($s)); $pos = mb_strpos($subject, $s, $pos + mb_strlen($r)); } } return $subject; }
/** * Smarty replace modifier plugin * * Type: modifier<br> * Name: replace<br> * Purpose: simple search/replace * * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @author Uwe Tews * @param string $ * @param string $ * @param string $ * @return string */ function smarty_modifier_replace($string, $search, $replace) { if (!function_exists("mb_str_replace")) { // simulate the missing PHP mb_str_replace function function mb_str_replace($needle, $replacement, $haystack) { $needle_len = mb_strlen($needle); $replacement_len = mb_strlen($replacement); $pos = mb_strpos($haystack, $needle, 0); while ($pos !== false) { $haystack = mb_substr($haystack, 0, $pos) . $replacement . mb_substr($haystack, $pos + $needle_len); $pos = mb_strpos($haystack, $needle, $pos + $replacement_len); } return $haystack; } } if (function_exists('mb_substr')) { return mb_str_replace($search, $replace, $string); } else { return str_replace($search, $replace, $string); } }
} } $back_url = implode('&', $back_url_params); //pull message information $message = new CForumMessage(); $message->load($message_id); //pull message information from last response if ($message_parent != -1) { $last_message = new CForumMessage(); $last_message->load($message_parent); if (!$last_message->message_id) { // if it's first response, use original message $last_message = clone $message; $last_message->message_body = wordwrap($last_message->message_body, 50, "\n> "); } else { $last_message->message_body = mb_str_replace("\n", "\n> ", $last_message->message_body); } } $crumbs = array(); $crumbs['?m=forums'] = 'forums list'; $crumbs['?m=forums&a=viewer&forum_id=' . $forum_id] = 'topics for this forum'; if ($message_parent > -1) { $crumbs['?m=forums&a=viewer&forum_id=' . $forum_id . '&message_id=' . $message_parent] = 'this topic'; } ?> <script language="javascript" type="text/javascript"> <?php // security improvement: // some javascript functions may not appear on client side in case of user not having write permissions // else users would be able to arbitrarily run 'bad' functions if ($canEdit || $canAdd) {
/** * SUBSTITUTE * * @param string $text Value * @param string $fromText From Value * @param string $toText To Value * @param integer $instance Instance Number * @return string */ public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) { $text = self::flattenSingleValue($text); $fromText = self::flattenSingleValue($fromText); $toText = self::flattenSingleValue($toText); $instance = floor(self::flattenSingleValue($instance)); if ($instance == 0) { if (function_exists('mb_str_replace')) { return mb_str_replace($fromText, $toText, $text); } else { return str_replace($fromText, $toText, $text); } } else { $pos = -1; while ($instance > 0) { if (function_exists('mb_strpos')) { $pos = mb_strpos($text, $fromText, $pos + 1, 'UTF-8'); } else { $pos = strpos($text, $fromText, $pos + 1); } if ($pos === false) { break; } --$instance; } if ($pos !== false) { if (function_exists('mb_strlen')) { return self::REPLACE($text, ++$pos, mb_strlen($fromText, 'UTF-8'), $toText); } else { return self::REPLACE($text, ++$pos, strlen($fromText), $toText); } } } return $left . $newText . $right; }
?> '; var sel_types = '<?php echo mb_str_replace(chr(10), '', $sel_types); ?> '; var sel_access = '<?php echo mb_str_replace(chr(10), '', $sel_access); ?> '; var sel_extra = '<?php echo mb_str_replace(chr(10), '', $sel_extra); ?> '; var sel_durntype = '<?php echo mb_str_replace(chr(10), '', $sel_durntype); ?> '; function addComponent() { var form = document.editFrm; var li = parseInt(form.nrcomponents.value); var line_nr = li+1; var ni = document.getElementById('tcomponents'); var li = li+1; priorities = sel_priorities.replace('priority0','priority_'+line_nr); priorities = priorities.replace('priority0','priority_'+line_nr); types = sel_types.replace('type0','type_'+line_nr); types = types.replace('type0','type_'+line_nr);
/** * @return string */ public function parse() { $this->buffer = $this->removeComments($this->buffer); if (!$this->importDisabled) { // Match all import types if (($match_count = preg_match_all('/@import\\s+(?:url\\()?["\\\']?([^"\\\'\\)]+)["\\\']?(?:\\))?(?:[\\s\\w\\d\\-._,]*);/i', $this->buffer, $matches)) > 0) { for ($i = 0; $i < $match_count; $i++) { if (!empty($matches[1][$i])) { $import_file = $this->findImport($matches[1][$i]); if ($import_file != null) { $child = $this->createChild($import_file); $child_contents = $child->parse(); $this->buffer = mb_str_replace($matches[0][$i], $child_contents, $this->buffer); } } } } } return $this->buffer; }
function rksnwp_en_div_to_p($theNote) { global $rksnwp_options; $bMarkdown = 0; if (!empty($rksnwp_options['core']['markdown'])) { $bMarkdown = 1; } if (in_array('md', $theNote['tag_names'])) { $bMarkdown = 1; } if (in_array('nomd', $theNote['tag_names'])) { $bMarkdown = 0; } if ($rksnwp_options['evernote']['div_to_p'] && !$bMarkdown) { $content = $theNote['content']; $content = preg_replace("/\n|\r/", '', $content); $content = mb_str_replace("\n\n", '<div><br/></div>', $content); $content = mb_str_replace('<div', '<p', $content); $content = mb_str_replace('</div>', "</p>\n", $content); $content = preg_replace("/<p><br[^>]*><\\/p>/", "", $content); $theNote['content'] = $content; } return $theNote; }
/** * * Liefert eine Zeile zum Eintragen des Betrages * * @param $i Nummer der Zeile * @param $rechnungsbetrag_id ID des rechnungsbetrages (optional) * @param $bezeichnung Bezeichnung des rechnungsbetrages (optional) * @param $betrag Betrag des rechnungsbetrages (optional) * @param $mwst MwSt des rechnungsbetrages (optional) */ function getBetragRow($i, $rechnungsbetrag_id = '', $bezeichnung = '', $betrag = '', $mwst = '') { $brutto = $betrag + $betrag * $mwst / 100; if ($betrag != '') { $betrag = sprintf("%01.2f", $betrag); } $betrag = mb_str_replace('.', ',', $betrag); return '<tr id="row_' . $i . '"> <td> <input type="hidden" name="rechnungsbetrag_id_' . $i . '" value="' . $rechnungsbetrag_id . '"> <input type="text" name="bezeichnung_' . $i . '" value="' . $bezeichnung . '"> </td> <td nowrap> <input class="number" type="text" size="12" maxlength="12" id="betrag_' . $i . '" name="betrag_' . $i . '" value="' . $betrag . '" onblur="checkNewRow(' . $i . '); replaceKomma(' . $i . ');" onchange="brutto(' . $i . '); summe()"> € </td> <td nowrap> <input class="number" type="text" size="5" maxlength="5" id="mwst_' . $i . '" name="mwst_' . $i . '" value="' . $mwst . '" onblur="replaceKomma(' . $i . ');" onchange="bruttonetto(' . $i . '); summe(); "> % </td> <td nowrap> <input class="number" type="text" size="12" maxlength="15" id="brutto_' . $i . '" name="brutto_' . $i . '" value="' . sprintf("%01.2f", $brutto) . '" onblur="replaceKomma(' . $i . ');" onchange="netto(' . $i . '); summe();"> € </td> <td> <input type="hidden" id="betragrechnung_' . $i . '" name="betragrechnung_' . $i . '" value="' . $betrag . '"> </td> </tr>'; }
function showtask_pr_ed(&$arr, $level = 0, $today_view = false) { global $AppUI, $done; //Check for Tasks Access $tmpTask = new CTask(); $tmpTask->load($arr['task_id']); $canAccess = $tmpTask->canAccess(); if (!$canAccess) { return false; } $htmlHelper = new w2p_Output_HTMLHelper($AppUI); $htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT'); $done[] = $arr['task_id']; $s = '<tr>'; // dots $s .= '<td style="width: ' . ($today_view ? '20%' : '50%') . '" class="data _name">'; for ($y = 0; $y < $level; $y++) { if ($y + 1 == $level) { $image = w2PfindImage('corner-dots.gif', $m); } else { $image = w2PfindImage('shim.gif', $m); } $s .= '<img src="' . $image . '" width="16" height="12" border="0" alt="" />'; } // name link $alt = mb_strlen($arr['task_description']) > 80 ? mb_substr($arr['task_description'], 0, 80) . '...' : $arr['task_description']; // instead of the statement below $alt = mb_str_replace('"', """, $alt); $alt = mb_str_replace("\r", ' ', $alt); $alt = mb_str_replace("\n", ' ', $alt); $open_link = w2PshowImage('collapse.gif'); if ($arr['task_milestone'] > 0) { $s .= ' <b>' . $arr["task_name"] . '</b><!--</a>--> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" alt="" />'; } elseif ($arr['task_dynamic'] == '1') { $s .= $open_link; $s .= '<strong>' . $arr['task_name'] . '</strong>'; } else { $s .= $arr['task_name']; } $s .= '</td>'; $s .= $htmlHelper->createCell('task_percent_complete', $arr['task_percent_complete']); $s .= $htmlHelper->createCell('task_start_date', $arr['task_start_date']); $s .= $htmlHelper->createCell('task_end_date', $arr['task_end_date']); $s .= $htmlHelper->createCell('last_update', $arr['last_update']); $s .= '</tr>'; return $s; }
/** * CMonthCalendar::_drawEvents() * * { Description } * */ private function _drawEvents($day) { $s = ''; if (!isset($this->events[$day]) || $this->styleMain == 'minical') { return ''; } $events = $this->events[$day]; foreach ($events as $e) { $href = isset($e['href']) ? $e['href'] : null; $alt = isset($e['alt']) ? mb_str_replace("\n", ' ', $e['alt']) : null; $s .= '<br />'; $s .= $href ? '<a href="' . $href . '" class="event" title="' . $alt . '">' : ''; $s .= $e['text']; $s .= $href ? '</a>' : ''; } return $s; }
/** * Smarty escape modifier plugin * * Type: modifier<br> * Name: escape<br> * Purpose: escape string for output * * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @param string $string input string * @param string $esc_type escape type * @param string $char_set character set * @return string escaped input string */ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = SMARTY_RESOURCE_CHAR_SET) { if (!function_exists('mb_str_replace')) { // simulate the missing PHP mb_str_replace function function mb_str_replace($needles, $replacements, $haystack) { $rep = (array) $replacements; foreach ((array) $needles as $key => $needle) { $replacement = $rep[$key]; $needle_len = mb_strlen($needle); $replacement_len = mb_strlen($replacement); $pos = mb_strpos($haystack, $needle, 0); while ($pos !== false) { $haystack = mb_substr($haystack, 0, $pos) . $replacement . mb_substr($haystack, $pos + $needle_len); $pos = mb_strpos($haystack, $needle, $pos + $replacement_len); } } return $haystack; } } switch ($esc_type) { case 'html': return htmlspecialchars($string, ENT_QUOTES, $char_set); case 'htmlall': return htmlentities($string, ENT_QUOTES, $char_set); case 'url': return rawurlencode($string); case 'urlpathinfo': return str_replace('%2F', '/', rawurlencode($string)); case 'quotes': // escape unescaped single quotes return preg_replace("%(?<!\\\\)'%", "\\'", $string); case 'hex': // escape every character into hex $return = ''; for ($x = 0; $x < strlen($string); $x++) { $return .= '%' . bin2hex($string[$x]); } return $return; case 'hexentity': $return = ''; for ($x = 0; $x < strlen($string); $x++) { $return .= '&#x' . bin2hex($string[$x]) . ';'; } return $return; case 'decentity': $return = ''; for ($x = 0; $x < strlen($string); $x++) { $return .= '&#' . ord($string[$x]) . ';'; } return $return; case 'javascript': // escape quotes and backslashes, newlines, etc. return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/')); case 'mail': // safe way to display e-mail address on a web page if (function_exists('mb_substr')) { return mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); } else { return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); } case 'nonstd': // escape non-standard chars, such as ms document quotes $_res = ''; for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { $_ord = ord(substr($string, $_i, 1)); // non-standard char, escape it if ($_ord >= 126) { $_res .= '&#' . $_ord . ';'; } else { $_res .= substr($string, $_i, 1); } } return $_res; default: return $string; } }
/** * This function handles replacing image place holder #img1# with the HTML for that image * @param string - text of post * @param array - array of HTML for images for post */ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post_id, $image_pattern, $autoadd_images) { if (!$config['custom_image_field']) { $startIndex = $config['start_image_count_at_zero'] ? 0 : 1; $images = get_posts(array('post_parent' => $post_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_mime_type' => 'image')); DebugEcho("images in post: " . count($images)); if (count($images) > 0 && $config['auto_gallery']) { $imageTemplate = '[gallery]'; if ($config['images_append']) { $content .= "\n{$imageTemplate}"; DebugEcho("Auto gallery: append"); } else { $content = "{$imageTemplate}\n" . $content; DebugEcho("Auto gallery: prepend"); } return; } $pics = ""; $i = 0; foreach ($attachments as $attachementName => $imageTemplate) { // looks for ' #img1# ' etc... and replaces with image $img_placeholder_temp = rtrim(str_replace("%", intval($startIndex + $i), $image_pattern), '#'); DebugEcho("img_placeholder_temp: {$img_placeholder_temp}"); if (stristr($content, $img_placeholder_temp)) { // look for caption DebugEcho("Found {$img_placeholder_temp}"); $caption = ''; if (preg_match("/{$img_placeholder_temp} caption=(.*?)#/i", $content, $matches)) { //DebugDump($matches); $caption = trim($matches[1]); if (strlen($caption) > 2 && ($caption[0] == "'" || $caption[0] == '"')) { $caption = substr($caption, 1, strlen($caption) - 2); } DebugEcho("caption: {$caption}"); $img_placeholder_temp = substr($matches[0], 0, -1); DebugEcho($img_placeholder_temp); } else { DebugEcho("No caption found"); } DebugEcho("parameterize templete: " . $imageTemplate); $imageTemplate = mb_str_replace('{CAPTION}', htmlspecialchars($caption, ENT_QUOTES), $imageTemplate); DebugEcho("populated template: " . $imageTemplate); $img_placeholder_temp .= '#'; $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content); DebugEcho("post replace: {$content}"); } else { DebugEcho("No {$img_placeholder_temp} found"); $imageTemplate = str_replace('{CAPTION}', '', $imageTemplate); /* if using the gallery shortcode, don't add pictures at all */ if (!preg_match("/\\[gallery[^\\[]*\\]/", $content, $matches)) { $pics .= $imageTemplate; } else { DebugEcho("gallery detected, not inserting images"); } } $i++; } if ($autoadd_images) { if ($config['images_append']) { $content .= $pics; } else { $content = $pics . $content; } } } }
function highlight($text, $keyval) { global $ssearch; $txt = $text; $hicolor = array('#FFFF66', '#ADD8E6', '#90EE8A', '#FF99FF', '#FFA500', '#ADFF2F', '#00FFFF', '#FF69B4'); $keys = array(); $keys = !is_array($keyval) ? array($keyval) : $keyval; foreach ($keys as $key_idx => $key) { if (mb_strlen($key) > 0) { $key = stripslashes($key); $metacharacters = array('\\', '(', ')', '$', '[', '*', '+', '|', '.', '^', '?'); $metareplacement = array('\\\\', '\\(', '\\)', '\\$', '\\[', '\\*', '\\+', '\\|', '\\.', '\\^', '\\?'); $key = mb_str_replace($metacharacters, $metareplacement, $key); if (isset($ssearch['ignore_specchar']) && $ssearch['ignore_specchar'] == 'on') { if ($ssearch['ignore_case'] == 'on') { $txt = preg_replace('/' . recode2regexp_utf8($key) . '/i', '<span style="background:' . $hicolor[$key_idx] . '" >\\0</span>', $txt); } else { $txt = preg_replace('/' . recode2regexp_utf8($key) . '/', '<span style="background:' . $hicolor[$key_idx] . '" >\\0</span>', $txt); } } elseif (!isset($ssearch['ignore_specchar']) || $ssearch['ignore_specchar'] == '') { if ($ssearch['ignore_case'] == 'on') { $txt = preg_replace('/' . $key . '/i', '<span style="background:' . $hicolor[$key_idx] . '" >\\0</span>', $txt); } else { $txt = preg_replace('/' . $key . '/', '<span style="background:' . $hicolor[$key_idx] . '" >\\0</span>', $txt); } } else { $txt = preg_replace('/' . $key . '/i', '<span style="background:' . $hicolor[$key_idx] . '" >\\0</span>', $txt); } } } return $txt; }