本文整理汇总了PHP中io_readfile函数的典型用法代码示例。如果您正苦于以下问题:PHP io_readfile函数的具体用法?PHP io_readfile怎么用?PHP io_readfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了io_readfile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFileAsPicture
/**
* Adds the file $src as a picture file without adding it to the content.
* Returns name of the file in the document for reference.
*
* @param string $src
* @return string
*/
function addFileAsPicture($src)
{
$name = '';
if (file_exists($src)) {
list($ext, $mime) = mimetype($src);
$name = 'Pictures/' . md5($src) . '.' . $ext;
$this->addFile($name, $mime, io_readfile($src, false));
}
return $name;
}
示例2: getVersionData
/**
* Return DokuWiki's version (split up in date and type)
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getVersionData()
{
$version = array();
//import version string
if (@file_exists(DOKU_INC . 'VERSION')) {
//official release
$version['date'] = trim(io_readfile(DOKU_INC . 'VERSION'));
$version['type'] = 'Release';
} elseif (is_dir(DOKU_INC . '.git')) {
$version['type'] = 'Git';
$version['date'] = 'unknown';
$inventory = DOKU_INC . '.git/logs/HEAD';
if (is_file($inventory)) {
$sz = filesize($inventory);
$seek = max(0, $sz - 2000);
// read from back of the file
$fh = fopen($inventory, 'rb');
fseek($fh, $seek);
$chunk = fread($fh, 2000);
fclose($fh);
$chunk = trim($chunk);
$chunk = @array_pop(explode("\n", $chunk));
//last log line
$chunk = @array_shift(explode("\t", $chunk));
//strip commit msg
$chunk = explode(" ", $chunk);
array_pop($chunk);
//strip timezone
$date = date('Y-m-d', array_pop($chunk));
if ($date) {
$version['date'] = $date;
}
}
} else {
global $updateVersion;
$version['date'] = 'update version ' . $updateVersion;
$version['type'] = 'snapshot?';
}
return $version;
}
示例3: getVersion
/**
* Return DokuWikis version
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getVersion()
{
//import version string
if (@file_exists('VERSION')) {
//official release
return 'Release ' . trim(io_readfile(DOKU_INC . '/VERSION'));
} elseif (is_dir('_darcs')) {
//darcs checkout - read last 2000 bytes of inventory
$sz = filesize('_darcs/inventory');
$seek = max(0, $sz - 2000);
$fh = fopen('_darcs/inventory', 'rb');
fseek($fh, $seek);
$chunk = fread($fh, 2000);
fclose($fh);
$inv = preg_grep('#\\*\\*\\d{14}[\\]$]#', explode("\n", $chunk));
$cur = array_pop($inv);
preg_match('#\\*\\*(\\d{4})(\\d{2})(\\d{2})#', $cur, $matches);
return 'Darcs ' . $matches[1] . '-' . $matches[2] . '-' . $matches[3];
} else {
return 'snapshot?';
}
}
示例4: getVersionData
/**
* Return DokuWiki's version (split up in date and type)
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getVersionData()
{
$version = array();
//import version string
if (@file_exists(DOKU_INC . 'VERSION')) {
//official release
$version['date'] = trim(io_readfile(DOKU_INC . 'VERSION'));
$version['type'] = 'Release';
return $version;
} elseif (is_dir(DOKU_INC . '_darcs')) {
if (is_file(DOKU_INC . '_darcs/inventory')) {
$inventory = DOKU_INC . '_darcs/inventory';
} elseif (is_file(DOKU_INC . '_darcs/hashed_inventory')) {
$inventory = DOKU_INC . '_darcs/hashed_inventory';
} else {
$version['date'] = 'unknown';
$version['type'] = 'Darcs';
return $version;
}
//darcs checkout - read last 2000 bytes of inventory
$sz = filesize($inventory);
$seek = max(0, $sz - 2000);
$fh = fopen($inventory, 'rb');
fseek($fh, $seek);
$chunk = fread($fh, 2000);
fclose($fh);
preg_match_all('#\\*\\*(\\d{4})(\\d{2})(\\d{2})\\d{6}(?:\\]|$)#m', $chunk, $matches, PREG_SET_ORDER);
$version['date'] = implode('-', array_slice(array_pop($matches), 1));
$version['type'] = 'Darcs';
return $version;
} else {
$version['date'] = 'unknown';
$version['type'] = 'snapshot?';
return $version;
}
}
示例5: p_cached_instructions
/**
* Returns the render instructions for a file
*
* Uses and creates a serialized cache file
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function p_cached_instructions($file, $cacheonly = false, $id = '')
{
global $conf;
$cache = new cache_instructions($id, $file);
if ($cacheonly || $cache->useCache()) {
return $cache->retrieveCache();
} else {
if (@file_exists($file)) {
// no cache - do some work
$ins = p_get_instructions(io_readfile($file));
$cache->storeCache($ins);
return $ins;
}
}
return NULL;
}
示例6: _odtAddImage
/**
* @param string $src
* @param $width
* @param $height
* @param $align
* @param $title
* @param $style
* @param $returnonly
*/
function _odtAddImage($src, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL, $returnonly = false)
{
$doc = '';
if (file_exists($src)) {
list($ext, $mime) = mimetype($src);
$name = 'Pictures/' . md5($src) . '.' . $ext;
$this->docHandler->addFile($name, $mime, io_readfile($src, false));
} else {
$name = $src;
}
// make sure width and height are available
if (!$width || !$height) {
list($width, $height) = $this->_odtGetImageSize($src, $width, $height);
} else {
// Adjust values for ODT
$width = $this->adjustXLengthValueForODT($width);
$height = $this->adjustYLengthValueForODT($height);
}
if ($align) {
$anchor = 'paragraph';
} else {
$anchor = 'as-char';
}
if (!$style or !array_key_exists($style, $this->autostyles)) {
$style = $this->styleset->getStyleName('media ' . $align);
}
if ($title) {
$doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . ' Legend"
text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '">';
$doc .= '<draw:text-box>';
$doc .= '<text:p text:style-name="' . $this->styleset->getStyleName('legend center') . '">';
}
$doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . '"
text:anchor-type="' . $anchor . '" draw:z-index="0"
svg:width="' . $width . '" svg:height="' . $height . '" >';
$doc .= '<draw:image xlink:href="' . $this->_xmlEntities($name) . '"
xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>';
$doc .= '</draw:frame>';
if ($title) {
$doc .= $this->_xmlEntities($title) . '</text:p></draw:text-box></draw:frame>';
}
if ($returnonly) {
return $doc;
} else {
$this->doc .= $doc;
}
}
示例7: act_resendpwd
/**
* Send a new password
*
* This function handles both phases of the password reset:
*
* - handling the first request of password reset
* - validating the password reset auth token
*
* @author Benoit Chesneau <benoit@bchesneau.info>
* @author Chris Smith <chris@jalakai.co.uk>
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return bool true on success, false on any error
*/
function act_resendpwd()
{
global $lang;
global $conf;
global $auth;
if (!actionOK('resendpwd')) {
return false;
}
if (!$auth) {
return false;
}
// should not be able to get here without modPass being possible...
if (!$auth->canDo('modPass')) {
msg($lang['resendna'], -1);
return false;
}
$token = preg_replace('/[^a-f0-9]+/', '', $_REQUEST['pwauth']);
if ($token) {
// we're in token phase
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!@file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
return false;
}
$user = io_readfile($tfile);
@unlink($tfile);
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
$pass = auth_pwgen();
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
if (auth_sendPassword($user, $pass)) {
msg($lang['resendpwdsuccess'], 1);
} else {
msg($lang['regmailfail'], -1);
}
return true;
} else {
// we're in request phase
if (!$_POST['save']) {
return false;
}
if (empty($_POST['login'])) {
msg($lang['resendpwdmissing'], -1);
return false;
} else {
$user = trim($auth->cleanUser($_POST['login']));
}
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
// generate auth token
$token = md5(auth_cookiesalt() . $user);
//secret but user based
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
io_saveFile($tfile, $user);
$text = rawLocale('pwconfirm');
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@FULLNAME@', $userinfo['name'], $text);
$text = str_replace('@LOGIN@', $user, $text);
$text = str_replace('@TITLE@', $conf['title'], $text);
$text = str_replace('@CONFIRM@', $url, $text);
if (mail_send($userinfo['name'] . ' <' . $userinfo['mail'] . '>', $lang['regpwmail'], $text, $conf['mailfrom'])) {
msg($lang['resendpwdconfirm'], 1);
} else {
msg($lang['regmailfail'], -1);
}
return true;
}
return false;
// never reached
}
示例8: _notify
/**
* Sends a notify mail on new comment
*
* @param array $comment data array of the new comment
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Esther Brunner <wikidesign@gmail.com>
*/
function _notify($comment, &$subscribers)
{
global $conf;
global $ID;
global $INFO;
$notify_text = io_readfile($this->localfn('subscribermail'));
$confirm_text = io_readfile($this->localfn('confirmsubscribe'));
$subject_notify = '[' . $conf['title'] . '] ' . $this->getLang('mail_newcomment');
$subject_subscribe = '[' . $conf['title'] . '] ' . $this->getLang('subscribe');
$from = $conf['mailfrom'];
$from = str_replace('@USER@', $_SERVER['REMOTE_USER'], $from);
$from = str_replace('@NAME@', $INFO['userinfo']['name'], $from);
$from = str_replace('@MAIL@', $INFO['userinfo']['mail'], $from);
$search = array('@PAGE@', '@TITLE@', '@DATE@', '@NAME@', '@TEXT@', '@COMMENTURL@', '@UNSUBSCRIBE@', '@DOKUWIKIURL@');
// prepare email body
if ($conf['notify'] || $conf['subscribers']) {
$replace = array($ID, $conf['title'], dformat($comment['date']['created'], $conf['dformat']), $comment['user']['name'], $comment['raw'], wl($ID, '', true) . '#comment_' . $comment['cid'], wl($ID, 'do=unsubscribe', true, '&'), DOKU_URL);
$body = str_replace($search, $replace, $notify_text);
}
// send mail to notify address
if ($conf['notify']) {
$to = $conf['notify'];
mail_send($to, $subject_notify, $body, $from, '', '');
}
// notify page subscribers
if ($conf['subscribers']) {
$to = '';
// put all recipients in bcc field
$data = array('id' => $ID, 'addresslist' => '', 'self' => false);
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
$bcc = $data['addresslist'];
mail_send($to, $subject_notify, $body, $from, '', $bcc);
}
// notify comment subscribers
if (!empty($subscribers)) {
foreach ($subscribers as $mail => $data) {
$to = $mail;
if ($data['active']) {
$replace = array($ID, $conf['title'], dformat($comment['date']['created'], $conf['dformat']), $comment['user']['name'], $comment['raw'], wl($ID, '', true) . '#comment_' . $comment['cid'], wl($ID, 'do=discussion_unsubscribe&hash=' . $data['hash'], true, '&'), DOKU_URL);
$body = str_replace($search, $replace, $notify_text);
mail_send($to, $subject_notify, $body, $from);
} elseif (!$data['active'] && !$data['confirmsent']) {
$search = array('@PAGE@', '@TITLE@', '@SUBSCRIBE@', '@DOKUWIKIURL@');
$replace = array($ID, $conf['title'], wl($ID, 'do=discussion_confirmsubscribe&hash=' . $data['hash'], true, '&'), DOKU_URL);
$body = str_replace($search, $replace, $confirm_text);
mail_send($to, $subject_subscribe, $body, $from);
$subscribers[$mail]['confirmsent'] = true;
}
}
}
}
示例9: _notify
/**
* Sends a notify mail on new comment
*
* @param array $comment data array of the new comment
* @param array $subscribers data of the subscribers
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Esther Brunner <wikidesign@gmail.com>
*/
protected function _notify($comment, &$subscribers)
{
global $conf;
global $ID;
$notify_text = io_readfile($this->localfn('subscribermail'));
$confirm_text = io_readfile($this->localfn('confirmsubscribe'));
$subject_notify = '[' . $conf['title'] . '] ' . $this->getLang('mail_newcomment');
$subject_subscribe = '[' . $conf['title'] . '] ' . $this->getLang('subscribe');
$mailer = new Mailer();
if (empty($_SERVER['REMOTE_USER'])) {
$mailer->from($conf['mailfromnobody']);
}
$replace = array('PAGE' => $ID, 'TITLE' => $conf['title'], 'DATE' => dformat($comment['date']['created'], $conf['dformat']), 'NAME' => $comment['user']['name'], 'TEXT' => $comment['raw'], 'COMMENTURL' => wl($ID, '', true) . '#comment_' . $comment['cid'], 'UNSUBSCRIBE' => wl($ID, 'do=subscribe', true, '&'), 'DOKUWIKIURL' => DOKU_URL);
$confirm_replace = array('PAGE' => $ID, 'TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL);
$mailer->subject($subject_notify);
$mailer->setBody($notify_text, $replace);
// send mail to notify address
if ($conf['notify']) {
$mailer->bcc($conf['notify']);
$mailer->send();
}
// send email to moderators
if ($this->getConf('moderatorsnotify')) {
$mods = trim($this->getConf('moderatorgroups'));
if (!empty($mods)) {
global $auth;
// create a clean mods list
$mods = explode(',', $mods);
$mods = array_map('trim', $mods);
$mods = array_unique($mods);
$mods = array_filter($mods);
// search for moderators users
foreach ($mods as $mod) {
if (!$auth->isCaseSensitive()) {
$mod = utf8_strtolower($mod);
}
// create a clean mailing list
$dests = array();
if ($mod[0] == '@') {
foreach ($auth->retrieveUsers(0, 0, array('grps' => $auth->cleanGroup(substr($mod, 1)))) as $user) {
if (!empty($user['mail'])) {
array_push($dests, $user['mail']);
}
}
} else {
$userdata = $auth->getUserData($auth->cleanUser($mod));
if (!empty($userdata['mail'])) {
array_push($dests, $userdata['mail']);
}
}
$dests = array_unique($dests);
// notify the users
$mailer->bcc(implode(',', $dests));
$mailer->send();
}
}
}
// notify page subscribers
if (actionOK('subscribe')) {
$data = array('id' => $ID, 'addresslist' => '', 'self' => false);
if (class_exists('Subscription')) {
/* Introduced in DokuWiki 2013-05-10 */
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, array(new Subscription(), 'notifyaddresses'));
} else {
/* Old, deprecated default handler */
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
}
$to = $data['addresslist'];
if (!empty($to)) {
$mailer->bcc($to);
$mailer->send();
}
}
// notify comment subscribers
if (!empty($subscribers)) {
foreach ($subscribers as $mail => $data) {
$mailer->bcc($mail);
if ($data['active']) {
$replace['UNSUBSCRIBE'] = wl($ID, 'do=discussion_unsubscribe&hash=' . $data['hash'], true, '&');
$mailer->subject($subject_notify);
$mailer->setBody($notify_text, $replace);
$mailer->send();
} elseif (!$data['active'] && !$data['confirmsent']) {
$confirm_replace['SUBSCRIBE'] = wl($ID, 'do=discussion_confirmsubscribe&hash=' . $data['hash'], true, '&');
$mailer->subject($subject_subscribe);
$mailer->setBody($confirm_text, $confirm_replace);
$mailer->send();
$subscribers[$mail]['confirmsent'] = true;
}
}
}
//.........这里部分代码省略.........
示例10: act_resendpwd
/**
* Send a new password
*
* This function handles both phases of the password reset:
*
* - handling the first request of password reset
* - validating the password reset auth token
*
* @author Benoit Chesneau <benoit@bchesneau.info>
* @author Chris Smith <chris@jalakai.co.uk>
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return bool true on success, false on any error
*/
function act_resendpwd()
{
global $lang;
global $conf;
global $auth;
if (!actionOK('resendpwd')) {
msg($lang['resendna'], -1);
return false;
}
$token = preg_replace('/[^a-f0-9]+/', '', $_REQUEST['pwauth']);
if ($token) {
// we're in token phase - get user info from token
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!@file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
unset($_REQUEST['pwauth']);
return false;
}
// token is only valid for 3 days
if (time() - filemtime($tfile) > 3 * 60 * 60 * 24) {
msg($lang['resendpwdbadauth'], -1);
unset($_REQUEST['pwauth']);
@unlink($tfile);
return false;
}
$user = io_readfile($tfile);
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
if (!$conf['autopasswd']) {
// we let the user choose a password
// password given correctly?
if (!isset($_REQUEST['pass']) || $_REQUEST['pass'] == '') {
return false;
}
if ($_REQUEST['pass'] != $_REQUEST['passchk']) {
msg($lang['regbadpass'], -1);
return false;
}
$pass = $_REQUEST['pass'];
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
} else {
// autogenerate the password and send by mail
$pass = auth_pwgen();
if (!$auth->triggerUserMod('modify', array($user, array('pass' => $pass)))) {
msg('error modifying user data', -1);
return false;
}
if (auth_sendPassword($user, $pass)) {
msg($lang['resendpwdsuccess'], 1);
} else {
msg($lang['regmailfail'], -1);
}
}
@unlink($tfile);
return true;
} else {
// we're in request phase
if (!$_POST['save']) {
return false;
}
if (empty($_POST['login'])) {
msg($lang['resendpwdmissing'], -1);
return false;
} else {
$user = trim($auth->cleanUser($_POST['login']));
}
$userinfo = $auth->getUserData($user);
if (!$userinfo['mail']) {
msg($lang['resendpwdnouser'], -1);
return false;
}
// generate auth token
$token = md5(auth_cookiesalt() . $user);
//secret but user based
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', array('do' => 'resendpwd', 'pwauth' => $token), true, '&');
io_saveFile($tfile, $user);
$text = rawLocale('pwconfirm');
$text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
$text = str_replace('@FULLNAME@', $userinfo['name'], $text);
//.........这里部分代码省略.........
示例11: _odtAddImage
function _odtAddImage($src, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL)
{
if (file_exists($src)) {
list($ext, $mime) = mimetype($src);
$name = 'Pictures/' . md5($src) . '.' . $ext;
if (!$this->manifest[$name]) {
$this->manifest[$name] = $mime;
$this->ZIP->add_File(io_readfile($src, false), $name, 0);
}
} else {
$name = $src;
}
// make sure width and height are available
if (!$width || !$height) {
list($width, $height) = $this->_odtGetImageSize($src, $width, $height);
}
if ($align) {
$anchor = 'paragraph';
} else {
$anchor = 'as-char';
}
if (!$style or !array_key_exists($style, $this->autostyles)) {
$style = 'media' . $align;
}
if ($title) {
$this->doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . ' Legend"
text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '">';
$this->doc .= '<draw:text-box>';
$this->doc .= '<text:p text:style-name="legendcenter">';
}
$this->doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . '"
text:anchor-type="' . $anchor . '" draw:z-index="0"
svg:width="' . $width . '" svg:height="' . $height . '" >';
$this->doc .= '<draw:image xlink:href="' . $this->_xmlEntities($name) . '"
xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>';
$this->doc .= '</draw:frame>';
if ($title) {
$this->doc .= $this->_xmlEntities($title) . '</text:p></draw:text-box></draw:frame>';
}
}
示例12: _odtAddImage
function _odtAddImage($src, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL)
{
list($ext, $mime) = mimetype($src);
$name = 'Pictures/' . md5($src) . '.' . $ext;
if (!$this->manifest[$name]) {
$this->manifest[$name] = $mime;
$this->ZIP->add_File(io_readfile($src, false), $name, 0);
}
// make sure width and height is available
// FIXME we don't have the dimension of an external file
// (except it's cached, but this is not the default) there seems
// to be no way to specify "use original image" in ODF - thus
// a hardcoded default size of 200 pixel here
if (!$width || !$height) {
$info = getimagesize($src);
if (!$width) {
$width = $info[0];
$height = $info[1];
} else {
$height = round($width * $info[1] / $info[0]);
}
}
// convert from pixel to centimeters
$width = $width / 96.0 * 2.54;
$height = $height / 96.0 * 2.54;
// Don't be wider than the page
if ($width >= 17) {
// FIXME : this assumes A4 page format with 2cm margins
$width = $width . 'cm" style:rel-width="100%';
$height = $height . 'cm" style:rel-height="scale';
} else {
$width = $width . 'cm';
$height = $height . 'cm';
}
if ($align) {
$anchor = 'paragraph';
} else {
$anchor = 'as-char';
}
if (!$style or !array_key_exists($style, $this->autostyles)) {
$style = 'media' . $align;
}
if ($title) {
$this->doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . ' Legend"
text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '">';
$this->doc .= '<draw:text-box>';
$this->doc .= '<text:p text:style-name="legendcenter">';
}
$this->doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . '"
text:anchor-type="' . $anchor . '" draw:z-index="0"
svg:width="' . $width . '" svg:height="' . $height . '" >';
$this->doc .= '<draw:image xlink:href="' . $this->_xmlEntities($name) . '"
xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>';
$this->doc .= '</draw:frame>';
if ($title) {
$this->doc .= $this->_xmlEntities($title) . '</text:p></draw:text-box></draw:frame>';
}
}
示例13: _get_TEXT
/**
* Get plain text of the wikipage
*/
function _get_TEXT()
{
global $ID;
$basePage = $ID;
// check for perrmissions of type and base pages
if (auth_quickaclcheck($basePage) < 1) {
return false;
}
//get filename of the page
$filename = wikiFN($basePage);
$TEXT = io_readfile($filename);
return $TEXT;
}
示例14: _notify
/**
* Sends a notify mail on new comment
*
* @param array $comment data array of the new comment
* @param array $subscribers data of the subscribers
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Esther Brunner <wikidesign@gmail.com>
*/
function _notify($comment, &$subscribers)
{
global $conf;
global $ID;
$notify_text = io_readfile($this->localfn('subscribermail'));
$confirm_text = io_readfile($this->localfn('confirmsubscribe'));
$subject_notify = '[' . $conf['title'] . '] ' . $this->getLang('mail_newcomment');
$subject_subscribe = '[' . $conf['title'] . '] ' . $this->getLang('subscribe');
$mailer = new Mailer();
if (empty($_SERVER['REMOTE_USER'])) {
$mailer->from($conf['mailfromnobody']);
}
$replace = array('PAGE' => $ID, 'TITLE' => $conf['title'], 'DATE' => dformat($comment['date']['created'], $conf['dformat']), 'NAME' => $comment['user']['name'], 'TEXT' => $comment['raw'], 'COMMENTURL' => wl($ID, '', true) . '#comment_' . $comment['cid'], 'UNSUBSCRIBE' => wl($ID, 'do=subscribe', true, '&'), 'DOKUWIKIURL' => DOKU_URL);
$confirm_replace = array('PAGE' => $ID, 'TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL);
$mailer->subject($subject_notify);
$mailer->setBody($notify_text, $replace);
// send mail to notify address
if ($conf['notify']) {
$mailer->bcc($conf['notify']);
$mailer->send();
}
// notify page subscribers
if (actionOK('subscribe')) {
$data = array('id' => $ID, 'addresslist' => '', 'self' => false);
if (class_exists('Subscription')) {
/* Introduced in DokuWiki 2013-05-10 */
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, array(new Subscription(), 'notifyaddresses'));
} else {
/* Old, deprecated default handler */
trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
}
$to = $data['addresslist'];
if (!empty($to)) {
$mailer->bcc($to);
$mailer->send();
}
}
// notify comment subscribers
if (!empty($subscribers)) {
foreach ($subscribers as $mail => $data) {
$mailer->bcc($mail);
if ($data['active']) {
$replace['UNSUBSCRIBE'] = wl($ID, 'do=discussion_unsubscribe&hash=' . $data['hash'], true, '&');
$mailer->subject($subject_notify);
$mailer->setBody($notify_text, $replace);
$mailer->send();
} elseif (!$data['active'] && !$data['confirmsent']) {
$confirm_replace['SUBSCRIBE'] = wl($ID, 'do=discussion_confirmsubscribe&hash=' . $data['hash'], true, '&');
$mailer->subject($subject_subscribe);
$mailer->setBody($confirm_text, $confirm_replace);
$mailer->send();
$subscribers[$mail]['confirmsent'] = true;
}
}
}
}
示例15: search_regex
/**
* fulltext search helper
* searches a text file with a given regular expression
* no ACL checks are performed. This have to be done by
* the caller if necessary.
*
* @param array $data reference to array for results
* @param string $base base directory
* @param string $file file name to search in
* @param string $reg regular expression to search for
* @param array $words words that should be marked in the results
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
*
* @deprecated - fulltext indexer is used instead
*/
function search_regex(&$data, $base, $file, $reg, $words)
{
//get text
$text = io_readfile($base . '/' . $file);
//lowercase text (u modifier does not help with case)
$lctext = utf8_strtolower($text);
//do the fulltext search
$matches = array();
if ($cnt = preg_match_all('#' . $reg . '#usi', $lctext, $matches)) {
//this is not the best way for snippet generation but the fastest I could find
$q = $words[0];
//use first word for snippet creation
$p = utf8_strpos($lctext, $q);
$f = $p - 100;
$l = utf8_strlen($q) + 200;
if ($f < 0) {
$f = 0;
}
$snippet = '<span class="search_sep"> ... </span>' . htmlspecialchars(utf8_substr($text, $f, $l)) . '<span class="search_sep"> ... </span>';
$mark = '(' . join('|', $words) . ')';
$snippet = preg_replace('#' . $mark . '#si', '<strong class="search_hit">\\1</strong>', $snippet);
$data[] = array('id' => pathID($file), 'count' => preg_match_all('#' . $mark . '#usi', $lctext, $matches), 'poswords' => join(' ', $words), 'snippet' => $snippet);
}
return true;
}