本文整理汇总了PHP中PMF_String::strlen方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_String::strlen方法的具体用法?PHP PMF_String::strlen怎么用?PHP PMF_String::strlen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_String
的用法示例。
在下文中一共展示了PMF_String::strlen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logSearchTerm
/**
* Logging of search terms for improvements
*
* @param string $searchterm Search term
* @return void
*/
public function logSearchTerm($searchterm)
{
if (PMF_String::strlen($searchterm) == 0) {
return;
}
$date = new DateTime();
$query = sprintf("\n INSERT INTO\n %s\n (id, lang, searchterm, searchdate)\n VALUES\n (%d, '%s', '%s', '%s')", $this->_table, $this->db->nextID($this->_table, 'id'), $this->language, $this->db->escapeString($searchterm), $date->format('Y-m-d H:i:s'));
$this->db->query($query);
}
示例2: drawText
/**
* Draw the Text
*
* @return resource
*/
private function drawText()
{
$len = PMF_String::strlen($this->code);
$w1 = 15;
$w2 = $this->width / ($len + 1);
for ($p = 0; $p < $len; $p++) {
$letter = $this->code[$p];
if (count($this->fonts) > 0) {
$font = $this->fonts[rand(0, count($this->fonts) - 1)];
}
$size = rand(20, $this->height / 2.2);
$rotation = rand(-23, 23);
$y = rand($size + 3, $this->height - 5);
// $w1 += rand(- $this->width / 90, $this->width / 40 );
$x = $w1 + $w2 * $p;
$c1 = array();
// fore char color
$c2 = array();
// back char color
do {
$c1['r'] = mt_rand(30, 199);
} while ($c1['r'] == $this->_backgroundColor['r']);
do {
$c1['g'] = mt_rand(30, 199);
} while ($c1['g'] == $this->_backgroundColor['g']);
do {
$c1['b'] = mt_rand(30, 199);
} while ($c1['b'] == $this->_backgroundColor['b']);
$c1 = imagecolorallocate($this->img, $c1['r'], $c1['g'], $c1['b']);
do {
$c2['r'] = $c1['r'] < 100 ? $c1['r'] * 2 : mt_rand(30, 199);
} while ($c2['r'] == $this->_backgroundColor['r'] && $c2['r'] == $c1['r']);
do {
$c2['g'] = $c1['g'] < 100 ? $c1['g'] * 2 : mt_rand(30, 199);
} while ($c2['g'] == $this->_backgroundColor['g'] && $c2['g'] == $c1['g']);
do {
$c2['b'] = $c1['b'] < 100 ? $c1['b'] * 2 : mt_rand(30, 199);
} while ($c2['b'] == $this->_backgroundColor['b'] && $c2['b'] == $c1['b']);
$c2 = imagecolorallocate($this->img, $c2['r'], $c2['g'], $c2['b']);
// Add the letter
if (function_exists('imagettftext') && count($this->fonts) > 0) {
imagettftext($this->img, $size, $rotation, $x + 2, $y, $c2, $font, $letter);
imagettftext($this->img, $size, $rotation, $x + 1, $y + 1, $c2, $font, $letter);
imagettftext($this->img, $size, $rotation, $x, $y - 2, $c1, $font, $letter);
} else {
$size = 5;
$c3 = imagecolorallocate($this->img, 0, 0, 255);
$x = 20;
$y = 12;
$s = 30;
imagestring($this->img, $size, $x + 1 + $s * $p, $y + 1, $letter, $c3);
imagestring($this->img, $size, $x + $s * $p, $y, $letter, $c1);
}
}
return $this->img;
}
示例3: catch
$captcha->setSessionId($sids);
if (!is_null($showCaptcha)) {
$captcha->showCaptchaImg();
exit;
}
try {
$faqsession->userTracking('new_entry', 0);
} catch (PMF_Exception $e) {
// @todo handle the exception
}
// Get possible user input
$selectedQuestion = PMF_Filter::filterInput(INPUT_GET, 'question', FILTER_VALIDATE_INT);
$selectedCategory = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT);
$question = $readonly = '';
if (!is_null($selectedQuestion)) {
$oQuestion = $faq->getQuestion($selectedQuestion);
$question = $oQuestion['question'];
if (PMF_String::strlen($question)) {
$readonly = ' readonly';
}
}
$category->buildTree();
$categoryHelper = new PMF_Helper_Category();
$categoryHelper->setCategory($category);
$captchaHelper = new PMF_Helper_Captcha($faqConfig);
// Enable/Disable WYSIWYG editor
if ($faqConfig->get('main.enableWysiwygEditorFrontend')) {
$tpl->parseBlock('writeContent', 'enableWysiwygEditor', array('currentTimestamp' => $_SERVER['REQUEST_TIME']));
}
$tpl->parse('writeContent', array('msgNewContentHeader' => $PMF_LANG['msgNewContentHeader'], 'msgNewContentAddon' => $PMF_LANG['msgNewContentAddon'], 'lang' => $Language->getLanguage(), 'openQuestionID' => $selectedQuestion, 'defaultContentMail' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('email') : '', 'defaultContentName' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('display_name') : '', 'msgNewContentName' => $PMF_LANG['msgNewContentName'], 'msgNewContentMail' => $PMF_LANG['msgNewContentMail'], 'msgNewContentCategory' => $PMF_LANG['msgNewContentCategory'], 'printCategoryOptions' => $categoryHelper->renderOptions($selectedCategory), 'msgNewContentTheme' => $PMF_LANG['msgNewContentTheme'], 'readonly' => $readonly, 'printQuestion' => $question, 'msgNewContentArticle' => $PMF_LANG['msgNewContentArticle'], 'msgNewContentKeywords' => $PMF_LANG['msgNewContentKeywords'], 'msgNewContentLink' => $PMF_LANG['msgNewContentLink'], 'captchaFieldset' => $captchaHelper->renderCaptcha($captcha, 'add', $PMF_LANG['msgCaptcha'], $auth), 'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit']));
$tpl->merge('writeContent', 'index');
示例4: searchEngine
/**
* The main search function for the full text search
*
* TODO: add filter for (X)HTML tag names and attributes!
*
* @param string Text/Number (solution id)
* @param string '%' to avoid any category filtering
* @param boolean true to search over all languages
* @param boolean true to disable the results paging
* @param boolean true to use it for Instant Response
* @return string
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Adrianna Musiol <musiol@imageaccess.de>
* @since 2002-09-16
*/
function searchEngine($searchterm, $cat = '%', $allLanguages = true, $hasMore = false, $instantRespnse = false)
{
global $sids, $PMF_LANG, $plr, $LANGCODE, $faq, $current_user, $current_groups, $categoryLayout;
$_searchterm = PMF_htmlentities(stripslashes($searchterm), ENT_QUOTES, 'utf-8');
$seite = 1;
$output = '';
$num = 0;
$searchItems = array();
$langs = true == $allLanguages ? '&langs=all' : '';
$seite = PMF_Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);
$db = PMF_Db::getInstance();
$faqconfig = PMF_Configuration::getInstance();
$result = getSearchData(htmlentities($searchterm, ENT_COMPAT, 'utf-8'), true, $cat, $allLanguages);
$num = $db->numRows($result);
if (0 == $num) {
$output = $PMF_LANG['err_noArticles'];
}
$confPerPage = $faqconfig->get('main.numberOfRecordsPerPage');
$pages = ceil($num / $confPerPage);
$last = $seite * $confPerPage;
$first = $last - $confPerPage;
if ($last > $num) {
$last = $num;
}
if ($num > 0) {
$output .= '<p>' . $plr->GetMsg('plmsgSearchAmount', $num);
if ($hasMore && $pages > 1) {
$output .= sprintf($PMF_LANG['msgInstantResponseMaxRecords'], $confPerPage);
}
$output .= "</p>\n";
if (!$hasMore && $pages > 1) {
$output .= "<p><strong>" . $PMF_LANG["msgPage"] . $seite . " " . $PMF_LANG["msgVoteFrom"] . " " . $plr->GetMsg('plmsgPagesTotal', $pages) . "</strong></p>";
}
$output .= "<ul class=\"phpmyfaq_ul\">\n";
$faqUser = new PMF_Faq_User();
$faqGroup = new PMF_Faq_Group();
$counter = $displayedCounter = 0;
while (($row = $db->fetchObject($result)) && $displayedCounter < $confPerPage) {
$counter++;
if ($counter <= $first) {
continue;
}
$displayedCounter++;
$b_permission = false;
//Groups Permission Check
if ($faqconfig->get('main.permLevel') == 'medium') {
$perm_group = $faqGroup->fetch($row->id);
foreach ($current_groups as $value) {
if ($value == $perm_group->group_id) {
$b_permission = true;
}
}
}
if ($faqconfig->get('main.permLevel') == 'basic' || $b_permission) {
$perm_user = $faqUser->fetch($row->id);
foreach ($perm_user as $value) {
if ($value == -1) {
$b_permission = true;
break;
} elseif ((int) $value == $current_user) {
$b_permission = true;
break;
} else {
$b_permission = false;
}
}
}
if ($b_permission) {
$rubriktext = $categoryLayout->renderBreadcrumb(array($row->category_id));
$thema = chopString($row->thema, 15);
$content = chopString(strip_tags($row->content), 25);
$searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $searchterm);
$searchterm = preg_quote($searchterm, '/');
$searchItems = explode(' ', $searchterm);
if (PMF_String::strlen($searchItems[0]) > 1) {
foreach ($searchItems as $item) {
if (PMF_String::strlen($item) > 2) {
$thema = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $thema);
$content = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $content);
}
}
}
// Print the link to the faq record
//.........这里部分代码省略.........
示例5: renderMostPopularSearches
/**
* Renders the list of the most popular search terms
*
* @param array $mostPopularSearches Array with popular search terms
*
* @return string
*/
public function renderMostPopularSearches(array $mostPopularSearches)
{
$html = '<ul class="mostpopularsearcheslist">';
foreach ($mostPopularSearches as $searchItem) {
if (PMF_String::strlen($searchItem['searchterm']) > 0) {
$html .= sprintf('<li><a href="?search=%s&submit=Search&action=search">%s</a> (%dx)</li>', urlencode($searchItem['searchterm']), $searchItem['searchterm'], $searchItem['number']);
}
}
return $html . '</ul>';
}
示例6: sprintf
}
$faqvisits = PMF_Visits::getInstance();
$faqvisits->logViews($faq->faqRecord['id']);
$content = $faq->faqRecord['content'];
$thema = $faq->getRecordTitle($faq->faqRecord['id']);
// Add Glossary entries
$content = $oGlossary->insertItemsIntoContent($content);
$thema = $oGlossary->insertItemsIntoContent($thema);
// Set the path of the current category
$categoryName = $categoryLayout->renderBreadcrumb($categoryPath);
$changeLanguagePath = PMF_Link::getSystemRelativeUri() . sprintf('?%saction=artikel&cat=%d&id=%d&artlang=%s', $sids, $currentCategory, $id, $LANGCODE);
$oLink = new PMF_Link($changeLanguagePath);
$oLink->itemTitle = $faq->getRecordTitle($record_id, false);
$changeLanguagePath = $oLink->toString();
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
if (!is_null($highlight) && $highlight != "/" && $highlight != "<" && $highlight != ">" && PMF_String::strlen($highlight) > 3) {
$highlight = str_replace("'", "´", $highlight);
$highlight = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']'), '', $highlight);
$highlight = preg_quote($highlight, '/');
$searchItems = explode(' ', $highlight);
$attributes = array('href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'face', 'size', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup');
foreach ($searchItems as $item) {
$thema = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $item . '[^"]*")|' . '(\\s+)(' . $item . ')(\\s+)' . '/mis', 'highlight_no_links', $thema);
$content = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $item . '[^"]*")|' . '(\\s+)(' . $item . ')(\\s+)' . '/mis', 'highlight_no_links', $content);
}
}
// Hack: Apply the new SEO schema to those HTML anchors to
// other faq records (Internal Links) added with WYSIWYG Editor:
// href="index.php?action=artikel&cat=NNN&id=MMM&artlang=XYZ"
// Search for href attribute links
$oLnk->resetPool();
示例7: str_replace
// a. We use plain PMF urls w/o any SEO schema
$link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['url']);
// b. We use SEO PMF urls
if (PMF_SITEMAP_GOOGLE_USE_SEO) {
if (isset($item['thema'])) {
$oL = new PMF_Link($link);
$oL->itemTitle = $item['thema'];
$link = $oL->toString();
}
}
$sitemap .= buildSitemapNode(PMF_Link::getSystemUri('/sitemap.google.php') . $link, PMF_Date::createISO8601Date($item['date']), PMF_SITEMAP_GOOGLE_CHANGEFREQ_DAILY, $priority);
}
$sitemap .= '</urlset>';
$getgezip = PMF_Filter::filterInput(INPUT_GET, PMF_SITEMAP_GOOGLE_GET_GZIP, FILTER_VALIDATE_INT);
if (!is_null($getgezip) && 1 == $getgezip) {
if (function_exists('gzencode')) {
$sitemapGz = gzencode($sitemap);
header('Content-Type: application/x-gzip');
header('Content-Disposition: attachment; filename="' . PMF_SITEMAP_GOOGLE_FILENAME_GZ . '"');
header('Content-Length: ' . strlen($sitemapGz));
print $sitemapGz;
} else {
PMF_Helper_Http::getInstance()->printHTTPStatus404();
}
} else {
header('Content-Type: text/xml');
header('Content-Disposition: inline; filename="' . PMF_SITEMAP_GOOGLE_FILENAME . '"');
header('Content-Length: ' . PMF_String::strlen($sitemap));
print $sitemap;
}
$db->dbclose();
示例8: searchEngine
$record_ids = $tagging->getRecordsByTagId($inputTag);
$printResult = $faq->showAllRecordsByIds($record_ids);
}
//
// Handle the full text search stuff
//
if (!is_null($inputSearchTerm) || !is_null($search)) {
if (!is_null($inputSearchTerm)) {
$inputSearchTerm = $db->escapeString(strip_tags($inputSearchTerm));
}
if (!is_null($search)) {
$inputSearchTerm = $db->escapeString(strip_tags($search));
}
$printResult = searchEngine($inputSearchTerm, $inputCategory, $allLanguages);
$inputSearchTerm = stripslashes($inputSearchTerm);
$faqsearch->logSearchTerm($inputSearchTerm);
}
// Change a little bit the $searchCategory value;
$inputCategory = '%' == $inputCategory ? 0 : $inputCategory;
$faqsession->userTracking('fulltext_search', $inputSearchTerm);
$openSearchLink = sprintf('<a class="searchplugin" href="#" onclick="window.external.AddSearchProvider(\'%s/opensearch.php\');">%s</a>', PMF_Link::getSystemUri('/index.php'), $PMF_LANG['opensearch_plugin_install']);
$mostPopularSearches = '';
$mostPopularSearchData = $faqsearch->getMostPopularSearches($faqconfig->get('main.numberSearchTerms'));
foreach ($mostPopularSearchData as $searchItem) {
if (PMF_String::strlen($searchItem['searchterm']) > 0) {
$mostPopularSearches .= sprintf('<li><a href="?search=%s&submit=Search&action=search">%s</a> (%dx)</li>', urlencode($searchItem['searchterm']), $searchItem['searchterm'], $searchItem['number']);
}
}
$categoryLayout = new PMF_Category_Layout(new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryData)));
$tpl->processTemplate('writeContent', array('msgSearch' => $tagSearch ? $PMF_LANG['msgTagSearch'] : $PMF_LANG['msgSearch'], 'searchString' => PMF_String::htmlspecialchars($inputSearchTerm, ENT_QUOTES, 'utf-8'), 'searchOnAllLanguages' => $PMF_LANG['msgSearchOnAllLanguages'], 'checkedAllLanguages' => $allLanguages ? ' checked="checked"' : '', 'selectCategories' => $PMF_LANG['msgSelectCategories'], 'allCategories' => $PMF_LANG['msgAllCategories'], 'printCategoryOptions' => $categoryLayout->renderOptions(array($inputCategory)), 'writeSendAdress' => '?' . $sids . 'action=search', 'msgSearchWord' => $PMF_LANG['msgSearchWord'], 'printResult' => $printResult, 'openSearchLink' => $openSearchLink, 'msgMostPopularSearches' => $PMF_LANG['msgMostPopularSearches'], 'printMostPopularSearches' => '<ul class="phpmyfaq_ul">' . $mostPopularSearches . '</ul>'));
$tpl->includeTemplate('writeContent', 'index');
示例9: getTrackingFileDate
/**
* Returns the timestamp of a tracking file
*
* @param string $file Filename
* @param boolean $endOfDay End of day?
*
* @return integer
*/
public static function getTrackingFileDate($file, $endOfDay = false)
{
if (PMF_String::strlen($file) >= 16) {
$day = PMF_String::substr($file, 8, 2);
$month = PMF_String::substr($file, 10, 2);
$year = PMF_String::substr($file, 12, 4);
if (!$endOfDay) {
$time = mktime(0, 0, 0, $month, $day, $year);
} else {
$time = mktime(23, 59, 59, $month, $day, $year);
}
return $time;
} else {
return -1;
}
}
示例10: trim
// @todo: Start transaction for better recovery if something really bad happens
$dat = trim(PMF_String::substr($dat, 11));
$tbl = explode(' ', $dat);
$num = count($tbl);
for ($h = 0; $h < $num; $h++) {
$mquery[] = 'DELETE FROM ' . $tbl[$h];
}
$ok = 1;
}
if ($ok == 1) {
$table_prefix = '';
printf("<p>%s</p>\n", $PMF_LANG['ad_csv_prepare']);
while ($dat = fgets($handle, 65536)) {
$dat = trim($dat);
$backup_prefix_pattern = "-- pmftableprefix:";
$backup_prefix_pattern_len = PMF_String::strlen($backup_prefix_pattern);
if (PMF_String::substr($dat, 0, $backup_prefix_pattern_len) == $backup_prefix_pattern) {
$table_prefix = trim(PMF_String::substr($dat, $backup_prefix_pattern_len));
}
if (PMF_String::substr($dat, 0, 2) != '--' && $dat != '') {
$mquery[] = trim(PMF_String::substr($dat, 0, -1));
}
}
$k = 0;
$g = 0;
printf("<p>%s</p>\n", $PMF_LANG['ad_csv_process']);
$num = count($mquery);
$kg = '';
for ($i = 0; $i < $num; $i++) {
$mquery[$i] = alignTablePrefix($mquery[$i], $table_prefix, SQLPREFIX);
$kg = $db->query($mquery[$i]);
示例11: saveTags
/**
* Saves all tags from a FAQ record
*
* @param integer $record_id Record ID
* @param array $tags Array of tags
*/
public function saveTags($record_id, $tags)
{
if (!is_array($tags)) {
return false;
}
$current_tags = $this->getAllTags();
// Delete all tag references for the faq record
if (count($tags) > 0) {
$this->deleteTagsFromRecordId($record_id);
}
// Store tags and references for the faq record
foreach ($tags as $tagging_name) {
$tagging_name = trim($tagging_name);
if (PMF_String::strlen($tagging_name) > 0) {
if (!in_array(PMF_String::strtolower($tagging_name), array_map(array('PMF_String', 'strtolower'), $current_tags))) {
// Create the new tag
$new_tagging_id = $this->db->nextID(SQLPREFIX . 'faqtags', 'tagging_id');
$query = sprintf("\n INSERT INTO\n %sfaqtags\n (tagging_id, tagging_name)\n VALUES\n (%d, '%s')", SQLPREFIX, $new_tagging_id, $tagging_name);
$this->db->query($query);
// Add the tag reference for the faq record
$query = sprintf("\n INSERT INTO\n %sfaqdata_tags\n (record_id, tagging_id)\n VALUES\n (%d, %d)", SQLPREFIX, $record_id, $new_tagging_id);
$this->db->query($query);
} else {
// Add the tag reference for the faq record
$query = sprintf("\n INSERT INTO\n %sfaqdata_tags\n (record_id, tagging_id)\n VALUES\n (%d, %d)", SQLPREFIX, $record_id, array_search(PMF_String::strtolower($tagging_name), array_map(array('PMF_String', 'strtolower'), $current_tags)));
$this->db->query($query);
}
}
}
return true;
}
示例12: 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>';
}
}
示例13: PMF_Link
// b. We use SEO PMF urls
if (PMF_SITEMAP_GOOGLE_USE_SEO) {
if (isset($item['thema'])) {
$oL = new PMF_Link($link, $faqConfig);
$oL->itemTitle = $item['thema'];
$link = $oL->toString();
}
}
$sitemap .= buildSitemapNode($faqConfig->get('main.referenceURL') . $link, PMF_Date::createIsoDate($item['date'], DATE_W3C), PMF_SITEMAP_GOOGLE_CHANGEFREQ_DAILY, $priority);
}
$sitemap .= '</urlset>';
$response = new Response();
$getgezip = PMF_Filter::filterInput(INPUT_GET, PMF_SITEMAP_GOOGLE_GET_GZIP, FILTER_VALIDATE_INT);
if (!is_null($getgezip) && 1 == $getgezip) {
if (function_exists('gzencode')) {
$sitemapGz = gzencode($sitemap);
$response->headers->set('Content-Type', 'application/x-gzip');
$response->headers->set('Content-Disposition', 'attachment; filename="' . PMF_SITEMAP_GOOGLE_FILENAME_GZ . '"');
$response->headers->set('Content-Length', strlen($sitemapGz));
$response->setContent($sitemapGz);
} else {
$response->setStatusCode(404);
}
} else {
$response->headers->set('Content-Type', 'text/xml');
$response->headers->set('Content-Disposition', 'inline; filename="' . PMF_SITEMAP_GOOGLE_FILENAME . '"');
$response->headers->set('Content-Length', PMF_String::strlen($sitemap));
$response->setContent($sitemap);
}
$response->send();
$faqConfig->getDb()->close();
示例14: _utf8_to_ucs4
/**
* This converts an UTF-8 encoded string to its UCS-4 representation
* By talking about UCS-4 "strings" we mean arrays of 32bit integers representing
* each of the "chars". This is due to PHP not being able to handle strings with
* bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too.
* The following UTF-8 encodings are supported:
* bytes bits representation
* 1 7 0xxxxxxx
* 2 11 110xxxxx 10xxxxxx
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
* 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
* 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
* 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
* Each x represents a bit that can be used to store character data.
* The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000
* @param string $input
* @return string
*/
private function _utf8_to_ucs4($input)
{
$output = array();
$out_len = 0;
$inp_len = PMF_String::strlen($input);
$mode = 'next';
$test = 'none';
for ($k = 0; $k < $inp_len; ++$k) {
$v = ord($input[$k]);
// Extract byte from input string
if ($v < 128) {
// We found an ASCII char - put into stirng as is
$output[$out_len] = $v;
++$out_len;
if ('add' == $mode) {
$this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k);
return false;
}
continue;
}
if ('next' == $mode) {
// Try to find the next start byte; determine the width of the Unicode char
$start_byte = $v;
$mode = 'add';
$test = 'range';
if ($v >> 5 == 6) {
// &110xxxxx 10xxxxx
$next_byte = 0;
// Tells, how many times subsequent bitmasks must rotate 6bits to the left
$v = $v - 192 << 6;
} elseif ($v >> 4 == 14) {
// &1110xxxx 10xxxxxx 10xxxxxx
$next_byte = 1;
$v = $v - 224 << 12;
} elseif ($v >> 3 == 30) {
// &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
$next_byte = 2;
$v = $v - 240 << 18;
} elseif ($v >> 2 == 62) {
// &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
$next_byte = 3;
$v = $v - 248 << 24;
} elseif ($v >> 1 == 126) {
// &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
$next_byte = 4;
$v = $v - 252 << 30;
} else {
$this->_error('This might be UTF-8, but I don\'t understand it at byte ' . $k);
return false;
}
if ('add' == $mode) {
$output[$out_len] = (int) $v;
++$out_len;
continue;
}
}
if ('add' == $mode) {
if (!$this->_allow_overlong && $test == 'range') {
$test = 'none';
if ($v < 0xa0 && $start_byte == 0xe0 || $v < 0x90 && $start_byte == 0xf0 || $v > 0x8f && $start_byte == 0xf4) {
$this->_error('Bogus UTF-8 character detected (out of legal range) at byte ' . $k);
return false;
}
}
if ($v >> 6 == 2) {
// Bit mask must be 10xxxxxx
$v = $v - 128 << $next_byte * 6;
$output[$out_len - 1] += $v;
--$next_byte;
} else {
$this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k);
return false;
}
if ($next_byte < 0) {
$mode = 'next';
}
}
}
// for
return $output;
}
示例15: strlen
/**
* Get string character count
*
* @param string $str String
*
* @return int
*/
public static function strlen($str)
{
return self::$instance->strlen($str);
}