本文整理汇总了PHP中PMF_String::preg_match方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_String::preg_match方法的具体用法?PHP PMF_String::preg_match怎么用?PHP PMF_String::preg_match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_String
的用法示例。
在下文中一共展示了PMF_String::preg_match方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setRelationLinks
/**
* Verlinkt einen Artikel dynamisch mit der Suche �ber die �bergebenen Schl�sselw�rter
*
* @param string $strHighlight
* @param string $strSource
* @param integer $intCount
* @return string
* @author Marco Enders <marco@minimarco.de>
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
public function setRelationLinks($strHighlight, $strSource, $intCount = 0)
{
global $in_content;
$x = 0;
$arrMatch = array();
PMF_String::preg_match_all('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', $strSource, $arrMatch);
$strSource = PMF_String::preg_replace('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', '~+*# replaced html #*+~', $strSource);
$x = $x + PMF_String::preg_match('/(' . preg_quote($strHighlight) . ')/ims', $strSource);
$strSource = PMF_String::preg_replace('/(' . preg_quote($strHighlight) . ')/ims', '<a href="index.php?action=search&search=' . $strHighlight . '" title="Insgesamt ' . $intCount . ' Artikel zu diesem Schlagwort (' . $strHighlight . ') vorhanden. Jetzt danach suchen..." class="relation">$1</a>', $strSource);
foreach ($arrMatch[0] as $html) {
$strSource = PMF_String::preg_replace('/' . preg_quote('~+*# replaced html #*+~') . '/', $html, $strSource, 1);
}
if ($x == 0) {
$in_content = false;
} else {
$in_content = true;
}
return $strSource;
}
示例2: search_vars
/**
*
* @param unknown_type $text
*/
private function search_vars($text)
{
if (DEBUG) {
$pattern = "/{(?!meta|baseHref|phpmyfaqversion)\\w+}/msi";
} else {
$pattern = "/{(?!debug|meta|baseHref|phpmyfaqversion)\\w+}/msi";
}
if (PMF_String::preg_match($pattern, $text)) {
return true;
} else {
return false;
}
}
示例3: preg_match
/**
*
* Match a regexp
* @param string $pattern
* @param string $subject
* @param array &$matches
* @param int $flags
* @param int $offset
*
* @return int
*/
public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
{
return self::$instance->preg_match($pattern, $subject, $matches, $flags, $offset);
}
示例4: getCurrentPageFromUrl
/**
* Returns the current page URL
*
* @param string $url URL
*
* @return integer
*/
protected function getCurrentPageFromUrl($url)
{
$page = 1;
if (!empty($url)) {
$match = array();
if (PMF_String::preg_match('$&(amp;|)' . $this->pageParamName . '=(\\d+)$', $url, $match)) {
$page = isset($match[2]) ? $match[2] : $page;
}
}
return $page;
}
示例5: header
header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
exit;
}
$faqsession->userTracking('sendmail_send2friend', 0);
$captcha = new PMF_Captcha($db, $Language);
$captcha->setSessionId($sids);
$name = PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$mailfrom = PMF_Filter::filterInput(INPUT_POST, 'mailfrom', FILTER_VALIDATE_EMAIL);
$mailto = PMF_Filter::filterInputArray(INPUT_POST, array('mailto' => array('filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_REQUIRE_ARRAY | FILTER_NULL_ON_FAILURE)));
$link = PMF_Filter::filterInput(INPUT_POST, 'link', FILTER_VALIDATE_URL);
$attached = PMF_Filter::filterInput(INPUT_POST, 'zusatz', FILTER_SANITIZE_STRIPPED);
$code = PMF_Filter::filterInput(INPUT_POST, 'captcha', FILTER_SANITIZE_STRING);
if (!is_null($name) && !is_null($mailfrom) && is_array($mailto) && IPCheck($_SERVER['REMOTE_ADDR']) && checkBannedWord(PMF_String::htmlspecialchars($attached)) && $captcha->checkCaptchaCode($code)) {
// Backward compatibility: extract article info from the link, no template change required
$cat = $id = $artlang = null;
PMF_String::preg_match('`index\\.php\\?action=artikel&cat=(?<cat>[\\d]+)&id=(?<id>[\\d]+)&artlang=(?<artlang>[^$]+)$`', $link, $matches);
if (isset($matches['cat'])) {
$cat = (int) $matches['cat'];
}
if (isset($matches['id'])) {
$id = (int) $matches['id'];
}
if (isset($matches['artlang'])) {
$artlang = $matches['artlang'];
}
// Sanity check
if (is_null($cat) || is_null($id) || is_null($artlang)) {
header('HTTP/1.1 403 Forbidden');
print 'Invalid FAQ link.';
exit;
}
示例6: _readBlocks
/**
* This function reads the block
*
* @param string $tpl Block to read
* @return string
*/
private function _readBlocks($tpl)
{
$tmpBlocks = array();
// read all blocks into $tmpBlocks
PMF_String::preg_match_all('/\\[.+\\]\\s*[\\W\\w\\s\\{\\}\\<\\>\\=\\"\\/]*?\\s*\\[\\/.+\\]/', $tpl, $tmpBlocks);
$unblocked = $tpl;
if (isset($tmpBlocks)) {
$blockCount = count($tmpBlocks[0]);
for ($i = 0; $i < $blockCount; $i++) {
$name = '';
//find block name
PMF_String::preg_match('/\\[.+\\]/', $tmpBlocks[0][$i], $name);
$name = PMF_String::preg_replace('/[\\[\\[\\/\\]]/', '', $name);
//remove block tags from block
$res = str_replace('[' . $name[0] . ']', '', $tmpBlocks[0][$i]);
$res = str_replace('[/' . $name[0] . ']', '', $res);
$tplBlocks[$name[0]] = $res;
//unblocked content
$unblocked = str_replace($tplBlocks[$name[0]], '', $unblocked);
$unblocked = str_replace('[' . $name[0] . ']', '', $unblocked);
$unblocked = str_replace('[/' . $name[0] . ']', '', $unblocked);
}
$hits = array();
PMF_String::preg_match_all('/\\{.+?\\}/', $unblocked, $hits);
$tplBlocks['unblocked'] = $hits[0];
} else {
// no blocks defined
$tplBlocks = $tpl;
}
return $tplBlocks;
}
示例7: getAllFirstLetters
/**
* Returns all available first letters
*
* @return array
* @since 2007-03-30
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
public function getAllFirstLetters()
{
global $sids;
if ($this->groupSupport) {
$permPart = sprintf("( fdg.group_id IN (%s)\n OR\n (fdu.user_id = %d AND fdg.group_id IN (%s)))", implode(', ', $this->groups), $this->user, implode(', ', $this->groups));
} else {
$permPart = sprintf("( fdu.user_id = %d OR fdu.user_id = -1 )", $this->user);
}
$writeLetters = '<p id="sitemapletters">';
switch ($this->type) {
case 'db2':
case 'sqlite':
$query = sprintf("\n SELECT\n DISTINCT UPPER(SUBSTR(fd.thema, 1, 1)) AS letters\n FROM\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s\n ORDER BY\n letters", SQLPREFIX, SQLPREFIX, SQLPREFIX, $this->language, $permPart);
break;
default:
$query = sprintf("\n SELECT\n DISTINCT UPPER(SUBSTRING(fd.thema, 1, 1)) AS letters\n FROM\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s\n ORDER BY\n letters", SQLPREFIX, SQLPREFIX, SQLPREFIX, $this->language, $permPart);
break;
}
$result = $this->db->query($query);
while ($row = $this->db->fetch_object($result)) {
$letters = PMF_String::strtoupper($row->letters);
if (PMF_String::preg_match("/^[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]/i", $letters)) {
$url = sprintf('%saction=sitemap&letter=%s&lang=%s', $sids, $letters, $this->language);
$oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
$oLink->text = (string) $letters;
$writeLetters .= $oLink->toHtmlAnchor() . ' ';
}
}
$writeLetters .= '</p>';
return $writeLetters;
}
示例8: isValIgnorable
/**
* Check if we can ignore a value while comparing. Actually
* catching empty and non alphanumeric strings
*
* @param string $val Value
*
* @return boolean
*/
public function isValIgnorable($val)
{
return PMF_String::preg_match('/^[^a-z0-9]*$/i', $val);
}
示例9: getCurrentPageFromUrl
protected function getCurrentPageFromUrl($url)
{
$retval = 1;
if (!empty($url)) {
$match = array();
switch ($this->urlStyle) {
case self::URL_STYLE_REWRITE:
$pattern = '$/(' . $this->pageParamName . ')/(\\d+)$';
break;
case self::URL_STYLE_DEFAULT:
default:
$pattern = '$&(amp;|)' . $this->pageParamName . '=(\\d+)$';
break;
}
if (PMF_String::preg_match($pattern, $url, $match)) {
$retval = isset($match[2]) ? $match[2] : $retval;
}
}
return $retval;
}
示例10: getAllFirstLetters
/**
* Returns all available first letters
*
* @return array
* @since 2007-03-30
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
public function getAllFirstLetters()
{
global $sids;
if ($this->groupSupport) {
$permPart = sprintf("( fdg.group_id IN (%s)\n OR\n (fdu.user_id = %d AND fdg.group_id IN (%s)))", implode(', ', $this->groups), $this->user, implode(', ', $this->groups));
} else {
$permPart = sprintf("( fdu.user_id = %d OR fdu.user_id = -1 )", $this->user);
}
$writeLetters = '<ul class="nav">';
if ($this->_config->getDb() instanceof PMF_DB_Sqlite || $this->_config->getDb() instanceof PMF_DB_Sqlite3) {
$query = sprintf("\n SELECT\n DISTINCT UPPER(SUBSTR(fd.thema, 1, 1)) AS letters\n FROM\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s\n ORDER BY\n letters", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $this->_config->getLanguage()->getLanguage(), $permPart);
} else {
$query = sprintf("\n SELECT\n DISTINCT UPPER(SUBSTRING(fd.thema, 1, 1)) AS letters\n FROM\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s\n ORDER BY\n letters", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $this->_config->getLanguage()->getLanguage(), $permPart);
}
$result = $this->_config->getDb()->query($query);
while ($row = $this->_config->getDb()->fetchObject($result)) {
$letters = PMF_String::strtoupper($row->letters);
if (PMF_String::preg_match("/^[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]/i", $letters)) {
$url = sprintf('%s?%saction=sitemap&letter=%s&lang=%s', PMF_Link::getSystemRelativeUri(), $sids, $letters, $this->_config->getLanguage()->getLanguage());
$oLink = new PMF_Link($url, $this->_config);
$oLink->text = (string) $letters;
$writeLetters .= '<li>' . $oLink->toHtmlAnchor() . '</li>';
}
}
$writeLetters .= '</ul>';
return $writeLetters;
}
示例11: text
/**
* schreiben eines Textes
*
* Diese Funktion schreibt einen Text
*
* @param string $textString
* @return string $textString
* @author David Sauer <david_sauer@web.de>
* @since 2005-07-21
*/
function text(&$textString)
{
if (PMF_String::preg_match('/((<)(.*)(>)?)/', $textString, $matches)) {
if (PMF_String::preg_match('/^((?!<)(.*?))((<(\\/?(.*)?)>)+)/', $textString, $matches) == true) {
$textStringPart = PMF_String::substr($textString, 0, PMF_String::strlen($matches[1]));
$textString = PMF_String::substr($textString, PMF_String::strlen($matches[1]));
} else {
$match = PMF_String::preg_match('/^(<\\/?(.*)>)/', $textString, $matchesRemainder);
if ($match) {
$textString = PMF_String::substr($textString, PMF_String::strlen($matchesRemainder[0]));
$textStringPart = '';
} else {
$textStringPart = '';
$textString = PMF_String::substr($textString, PMF_String::strlen($textString));
}
}
} else {
$textStringPart = $textString;
$textString = PMF_String::substr($textString, PMF_String::strlen($textString));
}
if (!empty($textStringPart)) {
$this->xmlContent .= '<para>';
$this->xmlContent .= $textStringPart;
$this->xmlContent .= '</para>';
}
}
示例12: _decode
/**
* The actual decoding algorithm
* @param string
* @return mixed
*/
private function _decode($encoded)
{
$decoded = array();
// find the Punycode prefix
if (!PMF_String::preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
$this->_error('This is not a punycode string');
return false;
}
$encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded);
// If nothing left after removing the prefix, it is hopeless
if (!$encode_test) {
$this->_error('The given encoded string was empty');
return false;
}
// Find last occurence of the delimiter
$delim_pos = strrpos($encoded, '-');
if ($delim_pos > strlen($this->_punycode_prefix)) {
for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
$decoded[] = ord($encoded[$k]);
}
}
$deco_len = count($decoded);
$enco_len = strlen($encoded);
// Wandering through the strings; init
$is_first = true;
$bias = $this->_initial_bias;
$idx = 0;
$char = $this->_initial_n;
for ($enco_idx = $delim_pos ? $delim_pos + 1 : 0; $enco_idx < $enco_len; ++$deco_len) {
for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) {
$digit = $this->_decode_digit($encoded[$enco_idx++]);
$idx += $digit * $w;
$t = $k <= $bias ? $this->_tmin : ($k >= $bias + $this->_tmax ? $this->_tmax : $k - $bias);
if ($digit < $t) {
break;
}
$w = (int) ($w * ($this->_base - $t));
}
$bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
$is_first = false;
$char += (int) ($idx / ($deco_len + 1));
$idx %= $deco_len + 1;
if ($deco_len > 0) {
// Make room for the decoded char
for ($i = $deco_len; $i > $idx; $i--) {
$decoded[$i] = $decoded[$i - 1];
}
}
$decoded[$idx++] = $char;
}
return $this->_ucs4_to_utf8($decoded);
}
示例13: quoted_printable_encode
function quoted_printable_encode($return = '')
{
// Ersetzen der lt. RFC 1521 noetigen Zeichen
$return = PMF_String::preg_replace('/([^\\t\\x20\\x2E\\041-\\074\\076-\\176])/ie', "sprintf('=%2X',ord('\\1'))", $return);
$return = PMF_String::preg_replace('!=\\ ([A-F0-9])!', '=0\\1', $return);
// Einfuegen von QP-Breaks (=\r\n)
if (PMF_String::strlen($return) > 75) {
$length = PMF_String::strlen($return);
$offset = 0;
do {
$step = 76;
$add_mode = $offset + $step < $length ? 1 : 0;
$auszug = PMF_String::substr($return, $offset, $step);
if (PMF_String::preg_match('!\\=$!', $auszug)) {
$step = 75;
}
if (PMF_String::preg_match('!\\=.$!', $auszug)) {
$step = 74;
}
if (PMF_String::preg_match('!\\=..$!', $auszug)) {
$step = 73;
}
$auszug = PMF_String::substr($return, $offset, $step);
$offset += $step;
$schachtel .= $auszug;
if (1 == $add_mode) {
$schachtel .= '=' . "\r\n";
}
} while ($offset < $length);
$return = $schachtel;
}
$return = PMF_String::preg_replace('!\\.$!', '. ', $return);
return PMF_String::preg_replace('!(\\r\\n|\\r|\\n)$!', '', $return) . "\r\n";
}