本文整理汇总了PHP中PMF_String::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_String::substr方法的具体用法?PHP PMF_String::substr怎么用?PHP PMF_String::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_String
的用法示例。
在下文中一共展示了PMF_String::substr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVars
/**
* Parse language file and get vars it does contain
*
* @param string $filepath Filepath
*
* @return array
*/
public function getVars($filepath)
{
$retval = array();
if (file_exists($filepath) && is_readable($filepath)) {
$orig = file($filepath);
while (list(, $line) = each($orig)) {
$line = rtrim($line);
/**
* Bypass all but variable definitions
*/
if (strlen($line) && '$' == $line[0]) {
/**
* $PMF_LANG["key"] = "val";
* or
* $PMF_LANG["key"] = array(0 => "something", 1 => ...);
* turns to something like array('$PMF_LANG["key"]', '"val";')
*/
$m = explode("=", $line, 2);
$key = str_replace(array('["', '"]', '[\'', '\']'), array('[', ']', '[', ']'), PMF_String::substr(trim($m[0]), 1));
$tmp = trim(@$m[1]);
if (0 === PMF_String::strpos($tmp, 'array')) {
$retval[$key] = PMF_String::substr($tmp, 0, -1);
} else {
$retval[$key] = stripslashes(PMF_String::substr($tmp, 1, -2));
}
}
}
}
return $retval;
}
示例2: printHTTPStatus404
function printHTTPStatus404()
{
if ('cgi' == PMF_String::substr(php_sapi_name(), 0, 3) || isset($_SERVER['ALL_HTTP'])) {
header('Status: 404 Not Found');
} else {
header('HTTP/1.0 404 Not Found');
}
exit;
}
示例3: getCategories
/**
* Gets the main categories and write them in an array
*
* @param string $categories Array of parent category ids
* @param boolean $parent_id Only top level categories?
*
* @return array
*/
public function getCategories($categories, $parent_id = true)
{
$_query = '';
$query = sprintf('
SELECT
id, lang, parent_id, name, description, user_id
FROM
%sfaqcategories
WHERE ', PMF_Db::getTablePrefix());
if (true == $parent_id) {
$query .= 'parent_id = 0';
}
foreach (explode(',', $categories) as $cats) {
$_query .= ' OR parent_id = ' . $cats;
}
if (false == $parent_id && 0 < PMF_String::strlen($_query)) {
$query .= PMF_String::substr($_query, 4);
}
if (isset($this->language) && preg_match("/^[a-z\\-]{2,}\$/", $this->language)) {
$query .= " AND lang = '" . $this->language . "'";
}
$query .= " ORDER BY id";
$result = $this->_config->getDb()->query($query);
while ($row = $this->_config->getDb()->fetchArray($result)) {
$this->categories[$row['id']] = $row;
}
return $this->categories;
}
示例4: array
}
if (!is_null($username) && !is_null($usermail) && !is_null($thema) && !is_null($content) && IPCheck($_SERVER['REMOTE_ADDR']) && checkBannedWord(PMF_String::htmlspecialchars($thema)) && checkBannedWord(PMF_String::htmlspecialchars($content)) && $captcha->checkCaptchaCode($code) && (is_null($faqid) && !is_null($categories) || !is_null($faqid) && !is_null($faqlanguage) && PMF_Language::isASupportedLanguage($faqlanguage))) {
$isNew = true;
if (!is_null($faqid)) {
$isNew = false;
$faqsession->userTracking('save_new_translation_entry', 0);
} else {
$faqsession->userTracking('save_new_entry', 0);
}
$isTranslation = false;
if (!is_null($faqlanguage)) {
$isTranslation = true;
$newLanguage = $faqlanguage;
}
if (PMF_String::substr($contentlink, 7) != "") {
$content = $content . "<br />" . $PMF_LANG["msgInfo"] . "<a href=\"http://" . PMF_String::substr($contentlink, 7) . "\" target=\"_blank\">" . $contentlink . "</a>";
}
$newData = array('lang' => $isTranslation == true ? $newLanguage : $LANGCODE, 'thema' => $thema, 'active' => FAQ_SQL_ACTIVE_NO, 'sticky' => 0, 'content' => $content, 'keywords' => $keywords, 'author' => $username, 'email' => $usermail, 'comment' => FAQ_SQL_YES, 'date' => date('YmdHis'), 'dateStart' => '00000000000000', 'dateEnd' => '99991231235959', 'linkState' => '', 'linkDateCheck' => 0);
$categoryNode = new PMF_Category_Node();
$categoryRelation = new PMF_Category_Relations();
$faqRecord = new PMF_Faq_Record();
if ($isNew) {
$newData['id'] = null;
$categories = $categoryNode->fetchAll($categories['rubrik']);
} else {
$newData['id'] = $faqid;
foreach ($categoryRelation->fetchAll() as $relation) {
if ($relation->record_id == $newData['id']) {
$categories[] = $relation;
}
}
示例5: makeAbsoluteURL
/**
* This function converts relative uri into absolute uri using specific reference point.
* For example,
* $relativeuri = "test/foo.html"
* $referenceuri = "http://example.com:8000/sample/index.php"
* will generate "http://example.com:8000/sample/test/foo.html"
*
* @param string $relativeuri
* @param string $message
* @return string $result
* @access private
* @author Minoru TODA <todam@netjapan.co.jp>
* @since 2005-08-01
*/
function makeAbsoluteURL($relativeuri = "", $referenceuri = "")
{
// If relativeuri is protocol we don't want to handle, don't process it.
foreach ($this->invalid_protocols as $_protocol => $_message) {
if (PMF_String::strpos($relativeuri, $_protocol) === 0) {
return $relativeuri;
}
}
// If relativeuri is absolute URI, don't process it.
foreach (array("http://", "https://") as $_protocol) {
if (PMF_String::strpos($relativeuri, $_protocol) === 0) {
return $relativeuri;
}
}
// Split reference uri into parts.
$pathparts = parse_url($referenceuri);
// If port is specified in reference uri, prefix with ":"
if (isset($pathparts['port']) && $pathparts['port'] != "") {
$pathparts['port'] = ":" . $pathparts['port'];
} else {
$pathparts['port'] = "";
}
// If path is not specified in reference uri, set as blank
if (isset($pathparts['path'])) {
$pathparts['path'] = str_replace("\\", "/", $pathparts['path']);
$pathparts['path'] = preg_replace("/^.*(\\/)\$/i", "", $pathparts['path']);
} else {
$pathparts['path'] = "";
}
// Recombine urls
if (PMF_String::substr($relativeuri, 0, 1) == "/") {
return $pathparts['scheme'] . "://" . $pathparts['host'] . $pathparts['port'] . $relativeuri;
} else {
return $pathparts['scheme'] . "://" . $pathparts['host'] . $pathparts['port'] . $pathparts['path'] . "/" . $relativeuri;
}
}
示例6: 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";
}
示例7: header
* @subpackage Frontend
* @author Thomas Zeithaml <seo@annatom.de>
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-08-21
* @version SVN: $Id$
* @copyright 2005-2009 phpMyFAQ Team
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*/
if (!defined('IS_VALID_PHPMYFAQ')) {
header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
exit;
}
$faqsession->userTracking('sitemap', 0);
$letter = PMF_Filter::filterInput(INPUT_GET, 'letter', FILTER_SANITIZE_STRIPPED);
if (!is_null($letter) && 1 == PMF_String::strlen($letter)) {
$currentLetter = strtoupper($db->escape_string(PMF_String::substr($letter, 0, 1)));
} else {
$currentLetter = 'A';
}
$sitemap = new PMF_Sitemap($current_user, $current_groups);
$tpl->processTemplate('writeContent', array('writeLetters' => $sitemap->getAllFirstLetters(), 'writeMap' => $sitemap->getRecordsFromLetter($currentLetter), 'writeCurrentLetter' => $currentLetter));
$tpl->includeTemplate('writeContent', 'index');
示例8: str_replace
?>
'<?php
print str_replace("\"", "´", $record['title']);
?>
'"><?php
print $record['title'];
?>
</a>
<?php
if (isset($numCommentsByFaq[$record['id']])) {
print " (" . $numCommentsByFaq[$record['id']] . " " . $PMF_LANG["ad_start_comments"] . ")";
}
?>
</td>
<td class="list" style="width: 48px;"><?php
print PMF_String::substr($record['date'], 0, 10);
?>
</td>
<td class="list" style="width: 96px;"><?php
print $linkverifier->getEntryStateHTML($record['id'], $record['lang']);
?>
</td>
<td class="list" style="width: 16px;">
<a href="#" onclick="javascript:deleteRecord(<?php
print $record['id'];
?>
, '<?php
print $record['lang'];
?>
');" title="<?php
print $PMF_LANG["ad_user_delete"];
示例9: search
/**
* Generates a result based on search a search string.
*
* This function generates a result set based on a search string.
* FIXME: can extend to handle operands like google
*
* @access public
* @author Tom Rochester <tom.rochester@gmail.com>
* @author Matteo scaramuccia <matteo@scaramuccia.com>
* @since 2005-02-21
*/
public function search($table, array $assoc, $joinedTable = '', array $joinAssoc = array(), $match = array(), $string = '', array $cond = array(), array $orderBy = array())
{
$string = $this->escape_string(trim($string));
$fields = "";
$joined = "";
$where = "";
foreach ($assoc as $field) {
if (empty($fields)) {
$fields = $field;
} else {
$fields .= ", " . $field;
}
}
if (isset($joinedTable) && $joinedTable != '') {
$joined .= ' LEFT JOIN ' . $joinedTable . ' ON ';
}
if (is_array($joinAssoc)) {
foreach ($joinAssoc as $joinedFields) {
$joined .= $joinedFields . ' AND ';
}
$joined = PMF_String::substr($joined, 0, -4);
}
foreach ($cond as $field => $data) {
if (empty($where)) {
$where .= $field . " = " . $data;
} else {
$where .= " AND " . $field . " = " . $data;
}
}
$match = implode(",", $match);
if (is_numeric($string)) {
$query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE " . $match . " = " . $string;
} else {
$query = "SELECT " . $fields . " FROM " . $table . $joined . " WHERE MATCH (" . $match . ") AGAINST ('" . $string . "' IN BOOLEAN MODE)";
}
if (!empty($where)) {
$query .= " AND (" . $where . ")";
}
$firstOrderBy = true;
foreach ($orderBy as $field) {
if ($firstOrderBy) {
$query .= " ORDER BY " . $field;
$firstOrderBy = false;
} else {
$query .= ", " . $field;
}
}
return $this->query($query);
}
示例10: aktually_date
/**
* Wandlung Timestamp
*
* Diese Funktion wandelt einen Timestamp in ein Datum
*
* @param string $date
* @return string $timestamp
* @author David Sauer <david_sauer@web.de>
* @since 2005-07-21
*/
function aktually_date($date)
{
$offset = 0;
$current = strtotime(PMF_String::substr($date, 0, 4) . "-" . PMF_String::substr($date, 4, 2) . "-" . PMF_String::substr($date, 6, 2) . " " . PMF_String::substr($date, 8, 2) . ":" . PMF_String::substr($date, 10, 2));
$timestamp = $current + $offset;
return date("Y-m-d H:i", $timestamp);
}
示例11: getRecordsByUnionTags
/**
* Returns all FAQ record IDs where all tags are included
*
* @param array $arrayOfTags Array of Tags
* @return array
*/
public function getRecordsByUnionTags($arrayOfTags)
{
if (!is_array($arrayOfTags)) {
return false;
}
$query = sprintf("\n SELECT\n d.record_id AS record_id\n FROM\n %sfaqdata_tags d, %sfaqtags t\n WHERE\n t.tagging_id = d.tagging_id\n AND\n (t.tagging_name IN ('%s'))\n GROUP BY\n d.record_id", SQLPREFIX, SQLPREFIX, PMF_String::substr(implode("', '", $arrayOfTags), 0, -2));
$records = array();
$result = $this->db->query($query);
while ($row = $this->db->fetchObject($result)) {
$records[] = $row->record_id;
}
return $records;
}
示例12: getRecordsFromLetter
/**
* Returns all records from the current first letter
*
* @param string $letter Letter
* @return array
* @since 2007-03-30
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
public function getRecordsFromLetter($letter = 'A')
{
global $sids, $PMF_LANG;
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);
}
$letter = PMF_String::strtoupper($this->db->escape_string(PMF_String::substr($letter, 0, 1)));
$writeMap = '';
switch ($this->type) {
case 'db2':
case 'sqlite':
$query = sprintf("\n SELECT\n fd.thema AS thema,\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.content AS snap\n FROM\n %sfaqcategoryrelations fcr,\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.id = fcr.record_id\n AND\n SUBSTR(fd.thema, 1, 1) = '%s'\n AND\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
break;
default:
$query = sprintf("\n SELECT\n fd.thema AS thema,\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.content AS snap\n FROM\n %sfaqcategoryrelations fcr,\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.id = fcr.record_id\n AND\n SUBSTRING(fd.thema, 1, 1) = '%s'\n AND\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
break;
}
$result = $this->db->query($query);
$oldId = 0;
while ($row = $this->db->fetch_object($result)) {
if ($oldId != $row->id) {
$title = PMF_String::htmlspecialchars($row->thema, ENT_QUOTES, 'utf-8');
$url = sprintf('%saction=artikel&cat=%d&id=%d&artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
$oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
$oLink->itemTitle = $row->thema;
$oLink->text = $title;
$oLink->tooltip = $title;
$writeMap .= '<li>' . $oLink->toHtmlAnchor() . '<br />' . "\n";
$writeMap .= PMF_Utils::chopString(strip_tags($row->snap), 25) . " ...</li>\n";
}
$oldId = $row->id;
}
$writeMap = empty($writeMap) ? '' : '<ul>' . $writeMap . '</ul>';
return $writeMap;
}
示例13: sendStatus
/**
* Returns a HTTP status header
*
* @param integer $code HTTP status code
*
* @return void
*/
public function sendStatus($code)
{
switch ($code) {
case 301:
header('HTTP/1.1 301 Moved Permanently');
break;
case 403:
header('HTTP/1.1 403 Forbidden');
break;
case 404:
if ('cgi' == PMF_String::substr(PHP_SAPI, 0, 3) || isset($_SERVER['ALL_HTTP'])) {
header('Status: 404 Not Found');
} else {
header('HTTP/1.0 404 Not Found');
}
break;
}
exit;
}
示例14: header
* obtain one at http://mozilla.org/MPL/2.0/.
*
* @category phpMyFAQ
* @package Frontend
* @author Thomas Zeithaml <seo@annatom.de>
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @copyright 2005-2015 phpMyFAQ Team
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
* @link http://www.phpmyfaq.de
* @since 2005-08-21
*/
if (!defined('IS_VALID_PHPMYFAQ')) {
$protocol = 'http';
if (isset($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) === 'ON') {
$protocol = 'https';
}
header('Location: ' . $protocol . '://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
exit;
}
$faqsession->userTracking('sitemap', 0);
$letter = PMF_Filter::filterInput(INPUT_GET, 'letter', FILTER_SANITIZE_STRIPPED);
if (!is_null($letter) && 1 == PMF_String::strlen($letter)) {
$currentLetter = strtoupper(PMF_String::substr($letter, 0, 1));
} else {
$currentLetter = '';
}
$sitemap = new PMF_Sitemap($faqConfig);
$sitemap->setUser($current_user);
$sitemap->setGroups($current_groups);
$tpl->parse('writeContent', array('writeLetters' => $sitemap->getAllFirstLetters(), 'writeMap' => $sitemap->getRecordsFromLetter($currentLetter), 'writeCurrentLetter' => empty($currentLetter) ? $PMF_LANG['msgSitemap'] : $currentLetter));
$tpl->merge('writeContent', 'index');
示例15: printf
$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]);
if (!$kg) {
printf('<div style="font-size: 9px;"><strong>Query</strong>: "%s" <span style="color: red;">failed (Reason: %s)</span></div>%s', PMF_String::htmlspecialchars($mquery[$i], ENT_QUOTES, 'utf-8'), $db->error(), "\n");
$k++;
} else {
printf('<!-- <div style="font-size: 9px;"><strong>Query</strong>: "%s" <span style="color: green;">okay</span></div> -->%s', PMF_String::htmlspecialchars($mquery[$i], ENT_QUOTES, 'utf-8'), "\n");