/** * 获取一个页面 * * @access public * @param string $gurl 操作地址 * @return string */ function CoOnePage($gurl) { global $dsql, $cfg_auot_description, $cfg_soft_lang; $redatas = array('title' => '', 'body' => '', 'source' => '', 'writer' => '', 'description' => '', 'keywords' => ''); $redatas['source'] = preg_replace("/http:\\/\\//i", "", $gurl); $redatas['source'] = preg_replace("/\\/(.*)\$/i", "", $redatas['source']); $row = $dsql->GetOne("SELECT * FROM `#@__co_onepage` WHERE url LIKE '" . $redatas['source'] . "' "); $s = $e = ''; if (is_array($row)) { list($s, $e) = explode('{@body}', $row['rule']); $s = trim($s); $e = trim($e); if ($row['issource'] == 1) { $redatas['source'] = $row['title']; } } $htd = new DedeHttpDown(); $htd->OpenUrl($gurl); $body = $htd->GetHtml(); if ($body != '') { //编码自动转换 if ($cfg_soft_lang == 'utf-8') { if ($row['lang'] == 'gb2312') { $body = gb2utf8($body); } } else { if ($cfg_soft_lang == 'gb2312') { if ($row['lang'] == 'utf-8') { $body = utf82gb($body); } } } //获取标题 $inarr = array(); preg_match("/<title>(.*)<\\/title>/isU", $body, $inarr); if (isset($inarr[1])) { $redatas['title'] = $inarr[1]; } //获取关键词 $inarr = array(); preg_match("/<meta[\\s]+name=['\"]keywords['\"] content=['\"](.*)['\"]/isU", $body, $inarr); if (isset($inarr[1])) { $redatas['keywords'] = cn_substr(html2text($inarr[1]), 30); } //获取摘要 $inarr = array(); preg_match("/<meta[\\s]+name=['\"]description['\"] content=['\"](.*)['\"]/isU", $body, $inarr); if (isset($inarr[1])) { $redatas['description'] = cn_substr(html2text($inarr[1]), $cfg_auot_description); } //获取内容 if ($s != '' && $e != '') { $redatas['body'] = GetHtmlAreaA($s, $e, $body); if ($redatas['body'] != '' && $redatas['description'] == '') { $redatas['description'] = cn_substr(html2text($redatas['body']), $GLOBALS['cfg_auot_description']); } } } return $redatas; }
/** * shorten text for preview * * @param string $text * input text * @param integer $lenght * @param integer $tolerance * how much additional lenght is acceptable * @return string shortend string */ function text_preview($text, $lenght, $tolerance) { $text = str_replace("<p", " <p", $text); $text = str_replace("<div", " <div", $text); $text = html2text($text); // remove HTML $text = substr($text, 0, $lenght + $tolerance + 20); // shorten to improve runtime if (strlen($text) < $lenght) { // if the text is to short, directly export it. return $text; } $separators = array(".", ",", " "); foreach ($separators as $separator) { $array = explode($separator, $text); $preview = ""; $j = 0; do { // add parts (sentences/words) until it is longer as $length $preview .= $array[$j] . $separator; $j += 1; } while (strlen($preview) < $lenght); if (strlen($preview) < $lenght + $tolerance) { // If the length is within the tolerance range, exit. // If not try again with a different separator. return $preview; } } return substr($text, 0, $lenght); // if it doesn't work, make a hard cut }
function GetOneArchive($aid) { global $dsql; include_once DEDEINC . "/channelunit.func.php"; $aid = trim(preg_replace('/[^0-9]/', '', $aid)); $reArr = array(); $chRow = $dsql->GetOne("SELECT arc.*,ch.maintable,ch.addtable,ch.issystem FROM `#@__arctiny` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='{$aid}' "); if (!is_array($chRow)) { return $reArr; } else { if (empty($chRow['maintable'])) { $chRow['maintable'] = '#@__archives'; } } if ($chRow['issystem'] != -1) { $nquery = " SELECT arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\n FROM `{$chRow['maintable']}` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n WHERE arc.id='{$aid}' "; } else { $nquery = " SELECT arc.*,1 AS ismake,0 AS money,'' AS filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\n FROM `{$chRow['addtable']}` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n WHERE arc.aid='{$aid}' "; } $arcRow = $dsql->GetOne($nquery); if (!is_array($arcRow)) { return $reArr; } if (!isset($arcRow['description'])) { $arcRow['description'] = ''; } if (empty($arcRow['description']) && isset($arcRow['body'])) { $arcRow['description'] = cn_substr(html2text($arcRow['body']), 250); } if (!isset($arcRow['pubdate'])) { $arcRow['pubdate'] = $arcRow['senddate']; } if (!isset($arcRow['notpost'])) { $arcRow['notpost'] = 0; } $reArr = $arcRow; $reArr['aid'] = $aid; $reArr['topid'] = $arcRow['topid']; $reArr['arctitle'] = $arcRow['title']; $reArr['arcurl'] = GetFileUrl($aid, $arcRow['typeid'], $arcRow['senddate'], $reArr['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']); return $reArr; }
Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_ANNOUNCEMENT, $id); $txt_content = ellipsize_html(canonicalize_whitespace(strip_tags($_POST['newContent'])), 50, '+'); Log::record($course_id, MODULE_ID_ANNOUNCE, $log_type, array('id' => $id, 'email' => $send_mail, 'title' => $_POST['antitle'], 'content' => $txt_content)); // send email if ($send_mail) { $recipients_emaillist = ""; foreach ($_POST['recipients'] as $re) { $recipients_emaillist .= empty($recipients_emaillist) ? "'{$re}'" : ",'{$re}'"; } $emailContent = "{$professorMessage}: " . q($_SESSION['givenname']) . " " . q($_SESSION['surname']) . "<br>\n<br>\n" . q($_POST['antitle']) . "<br>\n<br>\n" . $_POST['newContent']; $emailSubject = "{$professorMessage} ({$public_code} - " . q($title) . " - {$langAnnouncement})"; // select students email list $countEmail = 0; $invalid = 0; $recipients = array(); $emailBody = html2text($emailContent); $linkhere = " <a href='{$urlServer}main/profile/emailunsubscribe.php?cid={$course_id}'>{$langHere}</a>."; $unsubscribe = "<br /><br />{$langNote}: " . sprintf($langLinkUnsubscribe, $title); $emailContent .= $unsubscribe . $linkhere; $general_to = 'Members of course ' . $course_code; Database::get()->queryFunc("SELECT course_user.user_id as id, user.email as email\n FROM course_user, user\n WHERE course_id = ?d AND user.id IN ({$recipients_emaillist}) AND \n course_user.user_id = user.id", function ($person) use(&$countEmail, &$recipients, &$invalid, $course_id, $general_to, $emailSubject, $emailBody, $emailContent, $charset) { $countEmail++; $emailTo = $person->email; $user_id = $person->id; // check email syntax validity if (!email_seems_valid($emailTo)) { $invalid++; } elseif (get_user_email_notification($user_id, $course_id)) { // checks if user is notified by email array_push($recipients, $emailTo); }
/** * 解析模板,对内容里的变动进行赋值 * * @access public * @param string $pageNo 页码数 * @param string $ismake 是否生成 * @return string */ function ParseDMFields($pageNo, $ismake = 1) { $this->NowPage = $pageNo; $this->Fields['nowpage'] = $this->NowPage; if ($this->SplitPageField != '' && isset($this->Fields[$this->SplitPageField])) { $this->Fields[$this->SplitPageField] = $this->SplitFields[$pageNo - 1]; if ($pageNo > 1) { $this->Fields['description'] = trim(preg_replace("/[\r\n\t]/", ' ', cn_substr(html2text($this->Fields[$this->SplitPageField]), 200))); } } //解析模板 if (is_array($this->dtp->CTags)) { foreach ($this->dtp->CTags as $i => $ctag) { if ($ctag->GetName() == 'field') { $this->dtp->Assign($i, $this->GetField($ctag->GetAtt('name'), $ctag)); } else { if ($ctag->GetName() == 'pagebreak') { if ($ismake == 0) { $this->dtp->Assign($i, $this->GetPagebreakDM($this->TotalPage, $this->NowPage, $this->ArcID)); } else { $this->dtp->Assign($i, $this->GetPagebreak($this->TotalPage, $this->NowPage, $this->ArcID)); } } else { if ($ctag->GetName() == 'pagetitle') { if ($ismake == 0) { $this->dtp->Assign($i, $this->GetPageTitlesDM($ctag->GetAtt("style"), $pageNo)); } else { $this->dtp->Assign($i, $this->GetPageTitlesST($ctag->GetAtt("style"), $pageNo)); } } else { if ($ctag->GetName() == 'prenext') { $this->dtp->Assign($i, $this->GetPreNext($ctag->GetAtt('get'))); } else { if ($ctag->GetName() == 'fieldlist') { $innertext = trim($ctag->GetInnerText()); if ($innertext == '') { $innertext = GetSysTemplets('tag_fieldlist.htm'); } $dtp2 = new DedeTagParse(); $dtp2->SetNameSpace('field', '[', ']'); $dtp2->LoadSource($innertext); $oldSource = $dtp2->SourceString; $oldCtags = $dtp2->CTags; $res = ''; if (is_array($this->ChannelUnit->ChannelFields) && is_array($dtp2->CTags)) { foreach ($this->ChannelUnit->ChannelFields as $k => $v) { if (isset($v['autofield']) && empty($v['autofield'])) { continue; } $dtp2->SourceString = $oldSource; $dtp2->CTags = $oldCtags; $fname = $v['itemname']; foreach ($dtp2->CTags as $tid => $ctag2) { if ($ctag2->GetName() == 'name') { $dtp2->Assign($tid, $fname); } else { if ($ctag2->GetName() == 'tagname') { $dtp2->Assign($tid, $k); } else { if ($ctag2->GetName() == 'value') { $this->Fields[$k] = $this->ChannelUnit->MakeField($k, $this->Fields[$k], $ctag2); @$dtp2->Assign($tid, $this->Fields[$k]); } } } } $res .= $dtp2->GetResult(); } } $this->dtp->Assign($i, $res); } } } } } //end case } //结束模板循环 } }
/** * Replaces the placeholders with the content and returns * the rendered text if a text was set with "$mail->setBodyText()" * * @return string */ public function getBodyTextRendered() { $text = $this->getBodyText(); //if the content was manually set with $obj->setBodyText(); this content will be used if ($text instanceof Zend_Mime_Part) { $rawText = $text->getRawContent(); $content = $this->placeholderObject->replacePlaceholders($rawText, $this->getParams(), $this->getDocument(), $this->getEnableLayoutOnPlaceholderRendering()); } else { //creating text version from html email if html2text is installed try { include_once "simple_html_dom.php"; include_once "html2text.php"; $htmlContent = $this->getBodyHtmlRendered(); $html = str_get_html($htmlContent); if ($html) { $body = $html->find("body", 0); if ($body) { $htmlContent = $body->innertext; } } $content = @html2text($htmlContent); } catch (Exception $e) { Logger::err($e); $content = ""; } } return $content; }
$endtime = $senddate + 3600 * 24 * $endtime; $title = cn_substr($title,80); if($keywords!="") $keywords = trim(cn_substr($keywords,60))." "; //处理上传的缩略图 if(empty($ddisremote)) $ddisremote = 0; $litpic = GetDDImage('none',$picname,$ddisremote); $body = stripslashes($body); //自动摘要 if($description=="" && $cfg_auot_description>0){ $description = stripslashes(cn_substr(html2text($body),$cfg_auot_description)); $description = trim(preg_replace("/#p#|#e#/","",$description)); $description = addslashes($description); } //把内容中远程的图片资源本地化 //------------------------------------ if($cfg_isUrlOpen && $remote==1){ $body = GetCurContent($body); } //自动获取关键字 //---------------------------------- if($autokey==1){ require_once(DEDEADMIN."/../include/pub_splitword_www.php"); $keywords = ""; $sp = new SplitWord(); $titleindexs = explode(" ",trim($sp->GetIndexText($sp->SplitRMM($title))));
function get_less_variables() { $less_options = array(); global $get_less_variables_entry, $get_less_variables_data; if ($get_less_variables_entry) { return $get_less_variables_data; } @($file_pointer = fopen(file_require(get_template_directory() . "/assets/less/variables.less"), "r")); if ($file_pointer) { while (!feof($file_pointer)) { $line = fgets($file_pointer, 999); $line = trim($line . ''); if (substr($line, 0, 2) != "//" && strlen($line) > 3 && substr($line, 0, 1) == "@") { $splits = explode(':', $line); $variable = trim(str_replace('@', '', $splits[0])); $value = trim($splits[1]); if (strpos($value, '//') !== false) { $pos = explode('//', $value); $value = trim($pos[0]); } $value = str_replace(';', '', $value); $less_options[] = array('variable' => $variable, 'value' => $value); } else { if (substr($line, 0, 4) == '//**') { $variable = 'less-heading'; $value = str_replace('//**', '', $line); $less_options[] = array('variable' => $variable, 'value' => html2text($value)); } } } fclose($file_pointer); } $get_less_variables_entry = true; $get_less_variables_data = $less_options; return $less_options; }
// ok lets send the mails in packages of 30 mails, to prevent php timeout $count = $limit_data['count']; $finished = $count <= $limit_high; if ($finished) { $limit_high = $count; } $max_runtime = $limit_high - $limit_low; $newsletters_query = olc_db_query("SELECT\n title,\n body,\n bc,\n cc\n FROM " . TABLE_MODULE_NEWSLETTER . "\n WHERE newsletter_id='" . $id_get . APOS); $newsletters_data = olc_db_fetch_array($newsletters_query); $newsletters_title = $newsletters_data['title']; $newsletters_body_html = $newsletters_data['body']; $newsletters_body_text = html2text($newsletters_body_html); $newsletter_impressum_file = DIR_FS_CATALOG . "lang" . SLASH . SESSION_LANGUAGE . SLASH . "impressum" . HTML_EXT; if (is_file($newsletter_impressum_file)) { $newsletter_impressum_html = file_get_contents($newsletter_impressum_file); $newsletter_impressum_text = html2text($newsletter_impressum_html); } $remove_url0 = HTTP_CATALOG_SERVER . DIR_WS_CATALOG . FILENAME_CATALOG_NEWSLETTER . '?action=remove&x=true&email='; $two_nl = chr(10) . chr(10); $link_start = $two_nl . TEXT_NEWSLETTER_REMOVE_LINK . $two_nl . '#' . $remove_url0; $link_start_text = str_replace(HASH, EMPTY_STRING, $link_start); $link_start_html = str_replace(HASH, HTML_A_START, $link_start); $link_end_html = '">' . TEXT_NEWSLETTER_REMOVE . HTML_A_END . $two_nl . '(' . $remove_url0; $sql_update = SQL_UPDATE . $temp_table . " SET comment='send' WHERE id='"; for ($i = 1; $i <= $max_runtime; $i++) { // mail $i1 = $i - 1; $current_email_data = $email_data[$i1]; $email = $current_email_data['email']; $s = $email . '&key=' . $current_email_data['key']; $link_text = $link_start_text . $s;
public function __construct($data, $cron = false) { parent::__construct($data, $cron); $post = get_record_sql(' SELECT p.subject, p.body, p.poster, p.parent, ' . db_format_tsfield('p.ctime', 'ctime') . ', t.id AS topicid, fp.subject AS topicsubject, f.title AS forumtitle, g.id AS groupid, g.name AS groupname, f.id AS forumid FROM {interaction_forum_post} p INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic AND t.deleted = 0) INNER JOIN {interaction_forum_post} fp ON (fp.parent IS NULL AND fp.topic = t.id) INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted = 0) INNER JOIN {group} g ON (f.group = g.id AND g.deleted = 0) WHERE p.id = ? AND p.deleted = 0', array($this->postid)); // The post may have been deleted during the activity delay if (!$post) { $this->users = array(); return; } // Set notification to site admins. $siteadmins = activity_get_users($this->get_id(), null, null, true); // Get forum moderators and admins. $forumadminsandmoderators = activity_get_users($this->get_id(), array_merge(get_forum_moderators($post->forumid), group_get_admin_ids($post->groupid))); // Populate users to notify list and get rid of duplicates. foreach (array_merge($siteadmins, $forumadminsandmoderators) as $user) { if (!isset($this->users[$user->id])) { $this->users[$user->id] = $user; } } // Record who reported it. $this->fromuser = $this->reporter; $post->posttime = strftime(get_string('strftimedaydatetime'), $post->ctime); $post->textbody = trim(html2text($post->body)); $post->htmlbody = clean_html($post->body); $this->url = 'interaction/forum/topic.php?id=' . $post->topicid . '&post=' . $this->postid . '&objection=1'; $this->add_urltext(array('key' => 'Topic', 'section' => 'interaction.forum')); if ($this->event === REPORT_OBJECTIONABLE) { $this->overridemessagecontents = true; $this->strings->subject = (object) array('key' => 'objectionablecontentpost', 'section' => 'interaction.forum', 'args' => array($post->topicsubject, display_default_name($this->reporter))); } else { if ($this->event === MAKE_NOT_OBJECTIONABLE) { $this->strings = (object) array('subject' => (object) array('key' => 'postnotobjectionablesubject', 'section' => 'interaction.forum', 'args' => array($post->topicsubject, display_default_name($this->reporter))), 'message' => (object) array('key' => 'postnotobjectionablebody', 'section' => 'interaction.forum', 'args' => array(display_default_name($this->reporter), display_default_name($post->poster)))); } else { if ($this->event === DELETE_OBJECTIONABLE_POST) { $this->url = ''; $this->strings = (object) array('subject' => (object) array('key' => 'objectionablepostdeletedsubject', 'section' => 'interaction.forum', 'args' => array($post->topicsubject, display_default_name($this->reporter))), 'message' => (object) array('key' => 'objectionablepostdeletedbody', 'section' => 'interaction.forum', 'args' => array(display_default_name($this->reporter), display_default_name($post->poster), $post->textbody))); } else { if ($this->event === DELETE_OBJECTIONABLE_TOPIC) { $this->url = ''; $this->strings = (object) array('subject' => (object) array('key' => 'objectionabletopicdeletedsubject', 'section' => 'interaction.forum', 'args' => array($post->topicsubject, display_default_name($this->reporter))), 'message' => (object) array('key' => 'objectionabletopicdeletedbody', 'section' => 'interaction.forum', 'args' => array(display_default_name($this->reporter), display_default_name($post->poster), $post->textbody))); } else { throw new SystemException(); } } } } $this->temp = (object) array('post' => $post); }
</div> "; $emailfooter = " <!-- Footer Section --> <div id='mail-footer'> <br> <div> <small>" . sprintf($langLinkUnsubscribeFromPlatform, $siteName) ." <a href='${urlServer}main/profile/emailunsubscribe.php?cid=$course_id'>$langHere</a></small> </div> </div> "; $emailcontent = $emailheader.$emailmain.$emailfooter; $emailbody = html2text($emailcontent); if (count($recipients) >= 50) { send_mail_multipart('', '', '', $recipients, $emailsubject, $emailbody, $emailcontent, $charset); $recipients = array(); } } if (count($recipients) > 0) { send_mail_multipart('', '', '', $recipients, $emailsubject, $emailbody, $emailcontent, $charset); } // Display result and close table correctly $tool_content .= "<div class='alert alert-success'>$emailsuccess</div>"; } else { $body_mail = $email_title = ''; // Display form to administrator $tool_content .= "<div class='form-wrapper'> <form class='form-horizontal' role='form' action='$_SERVER[SCRIPT_NAME]' method='post'>
public function __construct($data) { parent::__construct($data); $this->overridemessagecontents = true; $post = get_record_sql(' SELECT p.subject, p.body, p.poster, p.parent, ' . db_format_tsfield('p.ctime', 'ctime') . ', t.id AS topicid, fp.subject AS topicsubject, f.title AS forumtitle, g.name AS groupname, f.id AS forumid FROM {interaction_forum_post} p INNER JOIN {interaction_forum_topic} t ON (t.id = p.topic AND t.deleted = 0) INNER JOIN {interaction_forum_post} fp ON (fp.parent IS NULL AND fp.topic = t.id) INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted = 0) INNER JOIN {group} g ON (f.group = g.id AND g.deleted = 0) WHERE p.id = ? AND p.deleted = 0', array($this->postid)); // The post may have been deleted during the activity delay if (!$post) { $this->users = array(); return; } $subscribers = get_records_sql_assoc(' SELECT "user" AS subscriber, \'topic\' AS type, "key" FROM {interaction_forum_subscription_topic} WHERE topic = ? UNION SELECT "user" AS subscriber, \'forum\' AS type, "key" FROM {interaction_forum_subscription_forum} WHERE forum = ? ORDER BY type', array($post->topicid, $post->forumid)); $this->users = $subscribers ? activity_get_users($this->get_id(), array_keys($subscribers)) : array(); $this->fromuser = $post->poster; // When emailing forum posts, create Message-Id headers for threaded display by email clients $urlinfo = parse_url(get_config('wwwroot')); $hostname = $urlinfo['host']; $cleanforumname = str_replace('"', "'", strip_tags($post->forumtitle)); $this->customheaders = array('List-Id: "' . $cleanforumname . '" <forum' . $post->forumid . '@' . $hostname . '>', 'List-Help: ' . get_config('wwwroot') . 'interaction/forum/view.php?id=' . $post->forumid, 'Message-ID: <forumpost' . $this->postid . '@' . $hostname . '>'); if ($post->parent) { $this->customheaders[] = 'In-Reply-To: <forumpost' . $post->parent . '@' . $hostname . '>'; $this->customheaders[] = 'References: <forumpost' . $post->parent . '@' . $hostname . '>'; } $posttime = strftime(get_string('strftimedaydatetime'), $post->ctime); $htmlbody = $post->body; $this->message = strip_tags(str_shorten_html($htmlbody, 200, true)); // For internal notifications. $textbody = trim(html2text($post->body)); $postlink = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topicid . '#post' . $this->postid; $this->url = $postlink; $this->add_urltext(array('key' => 'Topic', 'section' => 'interaction.forum')); foreach ($this->users as &$user) { $lang = empty($user->lang) || $user->lang == 'default' ? get_config('lang') : $user->lang; if ($post->parent) { $user->subject = get_string_from_language($lang, 'replyforumpostnotificationsubject', 'interaction.forum', $post->groupname, $post->forumtitle, $post->topicsubject); } else { $user->subject = get_string_from_language($lang, 'newforumpostnotificationsubject', 'interaction.forum', $post->groupname, $post->forumtitle, $post->subject); } $type = $subscribers[$user->id]->type; $unsubscribeid = $post->{$type . 'id'}; $unsubscribelink = get_config('wwwroot') . 'interaction/forum/unsubscribe.php?' . $type . '=' . $unsubscribeid . '&key=' . $subscribers[$user->id]->key; $user->emailmessage = get_string_from_language($lang, 'forumposttemplate', 'interaction.forum', $post->subject ? $post->subject : get_string_from_language($lang, 're', 'interaction.forum', $post->topicsubject), display_name($post->poster, $user), $posttime, $textbody, $postlink, $type, $unsubscribelink); $user->htmlmessage = get_string_from_language($lang, 'forumposthtmltemplate', 'interaction.forum', $post->subject ? $post->subject : get_string_from_language($lang, 're', 'interaction.forum', $post->topicsubject), display_name($post->poster, $user), $posttime, $htmlbody, $postlink, $unsubscribelink, $type); } }
/** * @param array $data Parameters: * - viewid (int) * - commentid (int) */ public function __construct($data, $cron = false) { parent::__construct($data, $cron); $comment = new ArtefactTypeComment($this->commentid); $this->overridemessagecontents = true; if ($onartefact = $comment->get('onartefact')) { // feedback on artefact $userid = null; require_once get_config('docroot') . 'artefact/lib.php'; $artefactinstance = artefact_instance_from_id($onartefact); if ($artefactinstance->feedback_notify_owner()) { $userid = $artefactinstance->get('owner'); } if (empty($this->url)) { $this->url = get_config('wwwroot') . 'view/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid; } } else { // feedback on view. $onview = $comment->get('onview'); if (!($viewrecord = get_record('view', 'id', $onview))) { throw new ViewNotFoundException(get_string('viewnotfound', 'error', $onview)); } $userid = $viewrecord->owner; if (empty($this->url)) { $this->url = get_config('wwwroot') . 'view/view.php?id=' . $onview; } } if (empty($userid)) { return; } $this->users = activity_get_users($this->get_id(), array($userid)); $title = $onartefact ? $artefactinstance->get('title') : $viewrecord->title; $this->urltext = $title; $body = $comment->get('description'); $posttime = strftime(get_string('strftimedaydatetime'), $comment->get('ctime')); $user = $this->users[0]; $lang = empty($user->lang) || $user->lang == 'default' ? get_config('lang') : $user->lang; // Internal $this->message = strip_tags(str_shorten_html($body, 200, true)); // Comment deleted notification if ($deletedby = $comment->get('deletedby')) { $this->strings = (object) array('subject' => (object) array('key' => 'commentdeletednotificationsubject', 'section' => 'artefact.comment', 'args' => array($title))); $deletedmessage = ArtefactTypeComment::deleted_messages(); $removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.comment'); $this->message = $removedbyline . ":\n" . $this->message; // Email $this->users[0]->htmlmessage = get_string_from_language($lang, 'feedbackdeletedhtml', 'artefact.comment', $title, $removedbyline, $body, $this->url, $title); $this->users[0]->emailmessage = get_string_from_language($lang, 'feedbackdeletedtext', 'artefact.comment', $title, $removedbyline, trim(html2text($body)), $title, $this->url); return; } $this->strings = (object) array('subject' => (object) array('key' => 'newfeedbacknotificationsubject', 'section' => 'artefact.comment', 'args' => array($title))); $this->url .= '&showcomment=' . $comment->get('id'); // Email $author = $comment->get('author'); $authorname = empty($author) ? $comment->get('authorname') : display_name($author, $user); $this->users[0]->htmlmessage = get_string_from_language($lang, 'feedbacknotificationhtml', 'artefact.comment', $authorname, $title, $posttime, $body, $this->url); $this->users[0]->emailmessage = get_string_from_language($lang, 'feedbacknotificationtext', 'artefact.comment', $authorname, $title, $posttime, trim(html2text($body)), $this->url); }
/** * generates text version of htmlContent * uses html2text binary if it was successfully enabled by calling * enableHtml2textBinary(), otherwise it uses html2text php version * @returns string */ protected function html2Text($htmlContent) { if ($this->getHtml2TextBinaryEnabled()) { $content = ""; //html2text doesn't support unicode if ($this->getCharset() == "UTF-8") { $htmlContent = utf8_decode($htmlContent); } //using temporary file so we don't have problems with special characters $tmpFileName = PIMCORE_TEMPORARY_DIRECTORY . "/" . uniqid('email_', true) . ".tmp"; if (\Pimcore\File::put($tmpFileName, $htmlContent)) { $content = @shell_exec("html2text {$tmpFileName} " . $this->getHtml2TextOptions()); @unlink($tmpFileName); } return $content; } else { return @html2text($htmlContent); } }
function locoyspider_addcompany($companyname) { global $locoyspider, $db; $setsqlarr['uid'] = locoyspider_user_register(check_email(trim($_POST['email']))); if ($setsqlarr['uid'] == "") { exit("添加会员出错"); } $setsqlarr['companyname'] = $companyname; $nature = locoyspider_company_nature(trim($_POST['nature'])); $setsqlarr['nature'] = $nature['id']; $setsqlarr['nature_cn'] = $nature['cn']; $trade = locoyspider_company_trade(trim($_POST['trade'])); $setsqlarr['trade'] = $trade['id']; $setsqlarr['trade_cn'] = $trade['cn']; $district = locoyspider_company_district(trim($_POST['district'])); $setsqlarr['district'] = $district['district']; $setsqlarr['sdistrict'] = $district['sdistrict']; $setsqlarr['district_cn'] = $district['district_cn']; $scale = locoyspider_company_scale(trim($_POST['scale'])); $setsqlarr['scale'] = $scale['id']; $setsqlarr['scale_cn'] = $scale['cn']; $registered = locoyspider_company_registered(trim($_POST['registered'])); $setsqlarr['registered'] = $registered['registered']; //注册资金 $setsqlarr['currency'] = $registered['currency']; //注册资金单位(人民币 or 美元) $setsqlarr['address'] = trim($_POST['address']); $setsqlarr['contact'] = trim($_POST['contact']); $setsqlarr['telephone'] = trim($_POST['telephone']); $setsqlarr['email'] = trim($_POST['email']); $setsqlarr['website'] = trim($_POST['website']); $setsqlarr['contents'] = html2text($_POST['contents']); $setsqlarr['audit'] = intval($locoyspider['company_audit']); $setsqlarr['addtime'] = time(); $setsqlarr['refreshtime'] = time(); $setsqlarr['robot'] = 1; //3.4新增字段,3.5也有 $setsqlarr['contact_show'] = 1; $setsqlarr['telephone_show'] = 1; $setsqlarr['email_show'] = 1; $setsqlarr['address_show'] = 1; if (!$db->inserttable(table('company_profile'), $setsqlarr)) { exit("添加企业出错"); } return true; }
<?php $autolitpic = (empty($autolitpic) ? '' : $autolitpic); ${$vs[0]} = stripslashes(${$vs[0]}); //获得文章body里的外部资源 if($cfg_isUrlOpen && $remote==1){ ${$vs[0]} = GetCurContent(${$vs[0]}); } //去除内容中的站外链接 if($dellink==1) { ${$vs[0]} = str_replace($cfg_basehost,'#basehost#',${$vs[0]}); ${$vs[0]} = preg_replace("/(<a[ \t\r\n]{1,}href=[\"']{0,}http:\/\/[^\/]([^>]*)>)|(<\/a>)/isU","",${$vs[0]}); ${$vs[0]} = str_replace('#basehost#',$cfg_basehost,${$vs[0]}); } //自动摘要 if($description=="" && $cfg_auot_description>0) { $description = cn_substr(html2text(${$vs[0]}),$cfg_auot_description); $description = trim(preg_replace("/#p#|#e#/","",$description)); $description = addslashes($description); $autodes = true; } //自动获取缩略图 if($autolitpic==1 && $litpic==''){ $litpic = GetDDImgFromBody(${$vs[0]}); $autopic = true; } ${$vs[0]} = addslashes(${$vs[0]}); ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID); ?>
function atm_byte($value, $datatype) { return ccstrlen($datatype == 'htmltext' ? html2text($value) : $value); }
/** * Given HTML text, make it into plain text using external function * * @uses $CFG * @param string $html The text to be converted. * @return string */ function html_to_text($html) { global $CFG; require_once $CFG->libdir . '/html2text.php'; return html2text($html); }
function GetOneArchive($aid) { global $dsql; include_once DEDEINC . "/channelunit.func.php"; $aid = trim(ereg_replace('[^0-9]', '', $aid)); $reArr = array(); $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `#@__arctiny` arc left join `#@__channeltype` ch on ch.id=arc.channel where arc.id='{$aid}' "); if (!is_array($chRow)) { return $reArr; } else { if (empty($chRow['maintable'])) { $chRow['maintable'] = '#@__archives'; } } if ($chRow['issystem'] != -1) { $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\t From `{$chRow['maintable']}` arc left join `#@__arctype` tp on tp.id=arc.typeid\r\n\t\t where arc.id='{$aid}' "; } else { $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\t From `{$chRow['addtable']}` arc left join `#@__arctype` tp on tp.id=arc.typeid\r\n\t\t where arc.aid='{$aid}' "; } $arcRow = $dsql->GetOne($nquery); if (!is_array($arcRow)) { return $reArr; } if (!isset($arcRow['description'])) { $arcRow['description'] = ''; } if (empty($arcRow['description']) && isset($arcRow['body'])) { $arcRow['description'] = cn_substr(html2text($arcRow['body']), 250); } if (!isset($arcRow['pubdate'])) { $arcRow['pubdate'] = $arcRow['senddate']; } if (!isset($arcRow['notpost'])) { $arcRow['notpost'] = 0; } $reArr = $arcRow; $reArr['aid'] = $aid; $reArr['topid'] = $arcRow['topid']; $reArr['arctitle'] = $arcRow['title']; $reArr['arcurl'] = GetFileUrl($aid, $arcRow['typeid'], $arcRow['senddate'], $reArr['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']); return $reArr; }
public function __construct($data) { parent::__construct($data); $this->users = activity_get_users($this->get_id(), $this->users); $post = get_record_sql('SELECT p.subject, p.body, p.poster, p.parent, t.id AS topicid, p2.subject AS topicsubject, f.title AS forumtitle, g.name AS groupname, f.id AS forumid FROM {interaction_forum_post} p INNER JOIN {interaction_forum_topic} t ON t.id = p.topic INNER JOIN {interaction_forum_post} p2 ON (p2.parent IS NULL AND p2.topic = t.id) INNER JOIN {interaction_instance} f ON t.forum = f.id INNER JOIN {group} g ON f.group = g.id WHERE p.id = ?', array($this->postid)); $this->url = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topicid . '#post' . $this->postid; // When emailing forum posts, create Message-Id headers for threaded display by email clients $urlinfo = parse_url(get_config('wwwroot')); $hostname = $urlinfo['host']; $cleanforumname = str_replace('"', "'", strip_tags($post->forumtitle)); $this->customheaders = array('Precedence: Bulk', 'List-Id: "' . $cleanforumname . '" <forum' . $post->forumid . '@' . $hostname . '>', 'List-Help: ' . get_config('wwwroot') . 'interaction/forum/view.php?id=' . $post->forumid, 'Message-ID: <forumpost' . $this->postid . '@' . $hostname . '>'); if ($post->parent) { $this->customheaders[] = 'In-Reply-To: <forumpost' . $post->parent . '@' . $hostname . '>'; $this->customheaders[] = 'References: <forumpost' . $post->parent . '@' . $hostname . '>'; } foreach ($this->users as &$user) { if ($post->parent) { $user->subject = get_string('replytotopicby', 'interaction.forum', $post->groupname, $post->forumtitle, $post->topicsubject, display_name($post->poster, $user)); } else { $user->subject = get_string('newforumpostby', 'interaction.forum', $post->groupname, $post->forumtitle, display_name($post->poster, $user)); } $user->message = ($post->subject ? $post->subject . "\n" . str_repeat('-', strlen($post->subject)) . "\n" : '') . trim(html2text($post->body)); } $this->unsubscribename = $post->forumtitle; $this->unsubscribeurl = get_config('wwwroot') . 'interaction/forum/view.php?id=' . $post->forumid; }
/** * @param array $data Parameters: * - viewid (int) * - annotationid (int) */ public function __construct($data, $cron = false) { parent::__construct($data, $cron); $annotation = new ArtefactTypeAnnotation($this->annotationid); $annotationfeedback = new ArtefactTypeAnnotationfeedback($this->annotationfeedbackid); $this->overridemessagecontents = true; if ($onartefact = $annotation->get('artefact')) { // Feedback on artefact. $userid = null; require_once get_config('docroot') . 'artefact/lib.php'; $artefactinstance = artefact_instance_from_id($onartefact); if ($artefactinstance->feedback_notify_owner()) { $userid = $artefactinstance->get('owner'); $groupid = $artefactinstance->get('group'); $institutionid = $artefactinstance->get('institution'); } if (empty($this->url)) { $this->url = 'artefact/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid; } } else { if ($onview = $annotation->get('view')) { // Feedback on view. if (!($viewrecord = get_record('view', 'id', $onview))) { throw new ViewNotFoundException(get_string('viewnotfound', 'error', $onview)); } $userid = $viewrecord->owner; $groupid = $viewrecord->group; $institutionid = $viewrecord->institution; if (empty($this->url)) { $this->url = 'view/view.php?id=' . $onview; } } else { // Something is wrong. throw new ViewNotFoundException(get_string('invalidannotationfeedbacklinkerror', 'artefact.annotation')); } } // Now fetch the users that will need to get notified about this event // depending on whether the page has an owner, group, or institution id set. if (!empty($userid)) { $this->users = activity_get_users($this->get_id(), array($userid)); } else { if (!empty($groupid)) { require_once get_config('docroot') . 'lib/group.php'; $sql = "SELECT u.*\n FROM {usr} u, {group_member} m, {group} g\n WHERE g.id = m.group\n AND m.member = u.id\n AND m.group = ?\n AND (g.feedbacknotify = " . GROUP_ROLES_ALL . "\n OR (g.feedbacknotify = " . GROUP_ROLES_NONMEMBER . " AND (m.role = 'tutor' OR m.role = 'admin'))\n OR (g.feedbacknotify = " . GROUP_ROLES_ADMIN . " AND m.role = 'admin')\n )"; $this->users = get_records_sql_array($sql, array($groupid)); } else { if (!empty($institutionid)) { require_once get_config('libroot') . 'institution.php'; $institution = new Institution($institutionid); $admins = $institution->institution_and_site_admins(); $this->users = get_records_sql_array("SELECT * FROM {usr} WHERE id IN (" . implode(',', $admins) . ")", array()); } } } if (empty($this->users)) { // no one to notify - possibe if group 'feedbacknotify' is set to 0 return; } $title = $onartefact ? $artefactinstance->get('title') : $viewrecord->title; $this->urltext = $title; $body = $annotationfeedback->get('description'); $posttime = strftime(get_string('strftimedaydatetime'), $annotationfeedback->get('ctime')); // Internal $this->message = strip_tags(str_shorten_html($body, 200, true)); // Seen as things like emaildigest base the message on $this->message // we need to set the language for the $removedbyline here based on first user. $user = $this->users[0]; $lang = empty($user->lang) || $user->lang == 'default' ? get_config('lang') : $user->lang; // Comment deleted notification if ($deletedby = $annotationfeedback->get('deletedby')) { $this->strings = (object) array('subject' => (object) array('key' => 'annotationfeedbackdeletednotificationsubject', 'section' => 'artefact.annotation', 'args' => array($title))); $deletedmessage = ArtefactTypeAnnotationfeedback::deleted_by_types_description(); $removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.annotation'); $this->message = $removedbyline . ":\n" . $this->message; foreach ($this->users as $key => $user) { if (empty($user->lang) || $user->lang == 'default') { // check to see if we need to show institution language $instlang = get_user_institution_language($user->id); $lang = empty($instlang) || $instlang == 'default' ? get_config('lang') : $instlang; } else { $lang = $user->lang; } // For email we can send the message in the user's preferred language $removedbyline = get_string_from_language($lang, $deletedmessage[$deletedby], 'artefact.annotation'); $this->users[$key]->htmlmessage = get_string_from_language($lang, 'annotationfeedbackdeletedhtml', 'artefact.annotation', hsc($title), $removedbyline, clean_html($body), get_config('wwwroot') . $this->url, hsc($title)); $this->users[$key]->emailmessage = get_string_from_language($lang, 'annotationfeedbackdeletedtext', 'artefact.annotation', $title, $removedbyline, trim(html2text(htmlspecialchars($body))), $title, get_config('wwwroot') . $this->url); } return; } $this->strings = (object) array('subject' => (object) array('key' => 'newannotationfeedbacknotificationsubject', 'section' => 'artefact.annotation', 'args' => array($title))); $this->url .= '&showcomment=' . $annotationfeedback->get('id'); // Email $author = $annotationfeedback->get('author'); foreach ($this->users as $key => $user) { $authorname = empty($author) ? $annotationfeedback->get('authorname') : display_name($author, $user); if (empty($user->lang) || $user->lang == 'default') { // check to see if we need to show institution language $instlang = get_user_institution_language($user->id); $lang = empty($instlang) || $instlang == 'default' ? get_config('lang') : $instlang; } else { $lang = $user->lang; } $this->users[$key]->htmlmessage = get_string_from_language($lang, 'annotationfeedbacknotificationhtml', 'artefact.annotation', hsc($authorname), hsc($title), $posttime, clean_html($body), get_config('wwwroot') . $this->url); $this->users[$key]->emailmessage = get_string_from_language($lang, 'annotationfeedbacknotificationtext', 'artefact.annotation', $authorname, $title, $posttime, trim(html2text(htmlspecialchars($body))), get_config('wwwroot') . $this->url); } }
/** * 处理HTML文本 * 删除非站外链接、自动摘要、自动获取缩略图 * * @access public * @param string $body 内容 * @param string $description 描述 * @param string $litpic 缩略图 * @param string $keywords 关键词 * @param string $dtype 类型 * @return string */ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = '') { global $autolitpic, $remote, $dellink, $autokey, $cfg_basehost, $cfg_auot_description, $id, $title, $cfg_soft_lang; $autolitpic = empty($autolitpic) ? '' : $autolitpic; $body = stripslashes($body); //远程图片本地化 if ($remote == 1) { $body = GetCurContent($body); } //删除非站内链接 if ($dellink == 1) { $allow_urls = array($_SERVER['HTTP_HOST']); // 读取允许的超链接设置 if (file_exists(DEDEDATA . "/admin/allowurl.txt")) { $allow_urls = array_merge($allow_urls, file(DEDEDATA . "/admin/allowurl.txt")); } $body = Replace_Links($body, $allow_urls); } //自动摘要 if ($description == '' && $cfg_auot_description > 0) { $description = cn_substr(html2text($body), $cfg_auot_description); $description = trim(preg_replace('/#p#|#e#/', '', $description)); $description = addslashes($description); } //自动获取缩略图 if ($autolitpic == 1 && $litpic == '') { $litpic = GetDDImgFromBody($body); } //自动获取关键字 if ($autokey == 1 && $keywords == '') { $subject = $title; $message = $body; include_once DEDEINC . '/splitword.class.php'; $keywords = ''; $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang); $sp->SetSource($subject, $cfg_soft_lang, $cfg_soft_lang); $sp->StartAnalysis(); $titleindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex()); $sp->SetSource(Html2Text($message), $cfg_soft_lang, $cfg_soft_lang); $sp->StartAnalysis(); $allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex()); if (is_array($allindexs) && is_array($titleindexs)) { foreach ($titleindexs as $k => $v) { if (strlen($keywords . $k) >= 60) { break; } else { if (strlen($k) <= 2) { continue; } $keywords .= $k . ','; } } foreach ($allindexs as $k => $v) { if (strlen($keywords . $k) >= 60) { break; } else { if (!in_array($k, $titleindexs)) { if (strlen($k) <= 2) { continue; } $keywords .= $k . ','; } } } } $sp = null; } $body = GetFieldValueA($body, $dtype, $id); $body = addslashes($body); return $body; }
} // INSERT INTO NEW SUPERVISOR REPORT LOG TOO $entry = 'Executive Notification - ' . $type . ' - ' . $_POST['parentTicket'] . ' - ' . $_POST['subject']; if ($_POST['update'] != "") { $entry .= "\n\n" . nl2br($_POST['update']); } // INCLUDE IT AS PART OF THE SUPEVISOR'S REPORT-SO-FAR $_SESSION['supReport'][date('Y-m-d G:i:s:u')] = array(date('D. @ G:i:s'), $netID, $entry); // INCLUDE UPDATES TO THE TICKET ITSELF try { $soapurl = getenv("SERVICENOWSTAGEURL") . "/incident.do?WSDL"; if ($env == 2) { $soapurl = getenv("SERVICENOWURL") . "/incident.do?WSDL"; } $incidentClient = new SoapClient($soapurl, array('trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_MEMORY, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'login' => $netID, 'password' => $passy)); $updateResponse = $incidentClient->update(array('sys_id' => $sysId, 'short_description' => $_POST['subject'], 'u_work_log' => "(Internal Comment)" . html2text($ticketEntry))); if (isset($updateResponse->sys_id)) { echo "<h2> Ticket's work-log has been updated successfully. </h2>"; } else { echo "<h2> Updating the work-log for the ticket failed. Please attempt to do so manually. </h2>"; } } catch (Exception $E) { if ($env == 2) { $errorInfo = ''; } else { $errorInfo = "ERROR " . print_r($E, true); } echo "<h2> Unable to connect to service-now to insert your update to the work-log. Please attempt to do so manually. <br><br>{$errorInfo}</h2>"; } $emailBody = formEmail($_POST); $subject = getEmailType($type) . $_POST['subject'];
/** * 按载入的网页内容获取规则,从一个HTML文件中获取内容 * * @access public * @param string $dourl 操作地址 * @param string $needDown 需要下载 * @param string $litpic 缩略图 * @return string */ function GetPageFields($dourl, $needDown, $litpic = '') { global $cfg_auot_description; if ($this->tmpHtml == '') { return ''; } $artitem = ''; $isPutUnit = FALSE; $tmpLtKeys = array(); $inarr = array(); //自动分析关键字和摘要 preg_match("#<meta[\\s]+name=['\"]keywords['\"] content=['\"](.*)['\"]#isU", $this->tmpHtml, $inarr); preg_match("#<meta[\\s]+content=['\"](.*)['\"] name=['\"]keywords['\"]#isU", $this->tmpHtml, $inarr2); if (!isset($inarr[1]) && isset($inarr2[1])) { $inarr[1] = $inarr2[1]; } if (isset($inarr[1])) { $keywords = trim(cn_substr(html2text($inarr[1]), 30)); $keywords = preg_replace("#" . $this->artNotes['keywordtrim'] . "#isU", '', $keywords); if (!preg_match("#,#", $keywords)) { $keywords = str_replace(' ', ',', $keywords); } $artitem .= "{dede:field name='keywords'}" . $keywords . "{/dede:field}\r\n"; } else { $artitem .= "{dede:field name='keywords'}{/dede:field}\r\n"; } // preg_match("#<meta[\s]+name=['\"]description['\"] content=['\"](.*)['\"]#isU", $this->tmpHtml, $inarr); // preg_match("#<meta[\s]+content=['\"](.*)['\"] name=['\"]description['\"]#isU", $this->tmpHtml, $inarr2); preg_match("#<meta[\\s]+name=['\"]description['\"][\\s]+content=['\"]([^>]*?)['\"]#iU", $this->tmpHtml, $inarr); preg_match("#<meta[\\s]+content=['\"]([^>]*?)['\"][\\s]+name=['\"]description['\"]#iU", $this->tmpHtml, $inarr2); if (!isset($inarr[1]) && isset($inarr2[1])) { $inarr[1] = $inarr2[1]; } if (isset($inarr[1])) { $description = trim(cn_substr(html2text($inarr[1]), $cfg_auot_description)); $description = preg_replace("/" . $this->artNotes['descriptiontrim'] . "/isU", '', $description); $artitem .= "{dede:field name='description'}" . $description . "{/dede:field}\r\n"; } else { $artitem .= "{dede:field name='description'}{/dede:field}\r\n"; } foreach ($this->artNotes as $k => $sarr) { //可能出现意外的情况 if ($k == 'sppage' || $k == 'sptype') { continue; } if (!is_array($sarr)) { continue; } //特殊的规则或没匹配选项 if ($sarr['match'] == '' || trim($sarr['match']) == '[内容]') { if ($sarr['value'] != '[内容]') { $v = trim($sarr['value']); } else { $v = ''; } } else { //分多页的内容 if ($this->tmpUnitValue != '' && !$isPutUnit && $sarr['isunit'] == 1) { $v = $this->tmpUnitValue; $isPutUnit = TRUE; } else { $v = $this->GetHtmlArea('[内容]', $sarr['match'], $this->tmpHtml); } //过滤内容规则 if (isset($sarr['trim']) && $v != '') { foreach ($sarr['trim'] as $nv) { if ($nv[0] == '') { continue; } $nvs = str_replace("/", "\\/", $nv[0]); $v = preg_replace("#" . $nvs . "#isU", $nv[1], $v); } } //是否下载远程资源 if ($needDown) { if ($sarr['isdown'] == '1') { $v = $this->DownMedias($v, $dourl); } } else { if ($sarr['isdown'] == '1') { $v = $this->MediasReplace($v, $dourl); } } } $v = trim($v); //用户自行对内容进行处理的接口 if ($sarr['function'] != '') { $tmpLtKeys[$k]['v'] = $v; $tmpLtKeys[$k]['f'] = $sarr['function']; } else { $v = preg_replace("#( )\$#", '', $v); $v = preg_replace("#[\r\n\t ]{1,}\$#", '', $v); $artitem .= "{dede:field name='{$k}'}{$v}{/dede:field}\r\n"; } } //End Foreach //处理带函数的项目 foreach ($tmpLtKeys as $k => $sarr) { $v = $this->RunPHP($sarr['v'], $sarr['f']); $v = preg_replace("#( )\$#", '', $v); $v = preg_replace("#[\r\n\t ]{1,}\$#", '', $v); $artitem .= "{dede:field name='{$k}'}{$v}{/dede:field}\r\n"; } if ($litpic != '' && $this->lists['listpic'] == 1) { $artitem .= "{dede:field name='litpic'}" . $this->DownMedia($litpic, 'img', TRUE) . "{/dede:field}\r\n"; } else { $artitem .= "{dede:field name='litpic'}" . $this->breImage . "{/dede:field}\r\n"; } return $artitem; }
Database::get()->query("UPDATE forum\n SET num_topics = num_topics+1,\n num_posts = num_posts+1,\n last_post_id = ?d\n\t\tWHERE id = ?d", $post_id, $forum_id); $topic = $topic_id; $total_forum = get_total_topics($forum_id); $total_topic = get_total_posts($topic) - 1; // subtract 1 because we want the number of replies, not the number of posts. // -------------------------------- // notify users // -------------------------------- $subject_notify = "{$logo} - {$langNewForumNotify}"; $category_id = forum_category($forum_id); $cat_name = category_name($category_id); $c = course_code_to_title($course_code); $name = uid_to_name($uid); $title = course_id_to_title($course_id); $forum_message = "-------- {$langBodyMessage} ({$langSender}: {$name})\n{$message}--------"; $plain_forum_message = q(html2text($forum_message)); $body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' \n {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' <br /><br />" . q($forum_message) . "<br />\n <br />{$gunet}<br /><a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>"; $plain_body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' \n\n{$plain_forum_message} \n\n{$gunet}\n<a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>"; $linkhere = " <a href='{$urlServer}main/profile/emailunsubscribe.php?cid={$course_id}'>{$langHere}</a>."; $unsubscribe = "<br /><br />{$langNote}: " . sprintf($langLinkUnsubscribe, $title); $plain_body_topic_notify .= $unsubscribe . $linkhere; $body_topic_notify .= $unsubscribe . $linkhere; $sql = Database::get()->queryArray("SELECT DISTINCT user_id FROM forum_notify\n\t\t\tWHERE (forum_id = ?d OR cat_id = ?d)\n\t\t\tAND notify_sent = 1 AND course_id = ?d AND user_id != ?d", $forum_id, $category_id, $course_id, $uid); foreach ($sql as $r) { if (get_user_email_notification($r->user_id, $course_id)) { $emailaddr = uid_to_email($r->user_id); send_mail_multipart('', '', '', $emailaddr, $subject_notify, $plain_body_topic_notify, $body_topic_notify, $charset); } } // end of notification Session::Messages($langStored, 'alert-success');
/** * format a message * * @param string $template * message template file name * * @return array * formated message data */ function _format($template) { $orig = $this->get('content'); $this->content = nl2br($this->get('content')); $tpl = new XTemplate("{$template}.html", getTemplateDir("{$template}.html", 'mail/')); $vars = get_object_vars($this); $tpl->assign('EMAIL', $vars); //read passed data if (is_array($GLOBALS['common_email'])) { $tpl->assign('DATA', $GLOBALS['common_email']); } // from $Onxshop_Request->_initTemplateVariables if ($_SERVER['SSL_PROTOCOL'] || $_SERVER['HTTPS']) { $protocol = 'https'; } else { $protocol = 'http'; } $tpl->assign('PROTOCOL', $protocol); $tpl->assign('URI', "{$protocol}://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"); $tpl->assign('_SERVER', $_SERVER); $tpl->assign('_SESSION', $_SESSION); $tpl->assign('CONFIGURATION', $GLOBALS['onxshop_conf']); $tpl->assign('_POST', $_POST); $tpl->assign('_GET', $_GET); $tpl->assign('GET', $_GET); // assign also to GET variable to keep consitent with normal templates initiated via a controller $tpl->assign('TIME', time()); /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); $tpl->assign('NODE_CONF', $node_conf); /** * parse */ $tpl->parse('title'); $tpl->parse('content'); $this->content = $orig; $data['title'] = $tpl->text('title'); $data['content']['html'] = $tpl->text('content'); //get the text version $data['content']['txt'] = html2text($data['content']['html']); //convert relative links to absolute $data['content']['html'] = $this->rel2abs("http://{$_SERVER['HTTP_HOST']}", $data['content']['html']); $data['content']['txt'] = $this->rel2abs("http://{$_SERVER['HTTP_HOST']}", $data['content']['txt']); return $data; }
<?php /** * Enter description here... * * @author Administrator * @package defaultPackage * @rcsfile $RCSfile: search.php,v $ * @revision $Revision: 1.1 $ * @date $Date: 2009/08/04 04:06:24 $ */ require_once dirname(__FILE__) . "/../include/common.inc.php"; require_once dirname(__FILE__) . '/include/story.view.class.php'; $kws = array(); if (!empty($id)) { $kws['id'] = intval($id); } if (!empty($keyword)) { $kws['keyword'] = html2text($keyword); } if (!empty($author)) { $kws['author'] = html2text($author); } if (count($kws) == 0) { ParamError(); } $bv = new BookView(0, 'search', $kws); $bv->Display(); $bv->Close();
/** * Returns a formatted upcoming event reminder message. * * @param int $eventid The ID of the event to format a message for. * @param string $type The type of event to format the message for. */ function elluminate_reminder_message($eventid, $type) { // Make sure the event exists if (!($event = $DB->get_record('event', array('id' => intval($eventid))))) { print_error('Invalid event ID: ' . $eventid); } switch ($type) { case 'user': $message = get_string('remindermessageuser', 'event_reminder'); break; case 'course': // Get the course record to format message variables $course = $DB->get_record('course', array('id' => $event->courseid)); $message = get_string('remindermessagecourse', 'event_reminder', $course->fullname); break; case 'group': // Get the group record to format message variables $group = $DB->get_record('groups', array('id' => $event->groupid)); $message = get_string('remindermessagegroup', 'event_reminder', $group->name); break; default: return NULL; break; } // Add the date for the event and the description for the event to the end of the message. $message .= userdate($event->timestart); $message .= get_string('remindereventdescription', 'event_reminder', html2text($event->description)); return $message; }
function html2text($string) { if (is_array($string)) { foreach ($string as $key => $val) { $string[$key] = html2text($val); } } else { $string = preg_replace(array('/<[\\/\\!]*?[^<>]*?>/is', '/\\s*/is'), '', $string); } return $string; }
ksort($src_print); if($check_updates == 'on') { $update_array = array(); $update_content = get_url_contents('http://projects.colsolgrp.net/projects/list_files/superfecta'); if(($update_content == '') || (strpos($update_content,'The system is currently in Maintenance Mode. Please try again later.') !== false)) { //site un-available, give error. $update_site_unavailable = true; $check_updates = 'off'; } else { $update_content = html2text($update_content); $update_content = substr($update_content,(strpos($update_content,'Caller ID Superfecta Source Files') + 33)); $update_content = substr($update_content,0,strpos($update_content,'[LINK: /versions/show')); $update_content = str_replace("\t","|||",$update_content); $update_content = str_replace("]","|||",$update_content); $update_content = str_replace("\n","",$update_content); $tmp_array = explode("[LINK: ",$update_content); foreach($tmp_array as $val) { $tmp2_array = explode("|||",$val); if(!empty($tmp2_array[0])) { $this_source_name = substr(substr(trim($tmp2_array[1]),7),0,-4); $update_array[$this_source_name]['link'] = "http://projects.colsolgrp.net".trim($tmp2_array[0]); $update_array[$this_source_name]['date'] = strtotime(trim($tmp2_array[2])) - (60*60*24); //to correct for time zones, give a time that is 24 hours older than the file actually is. }