function insert_wysiwyg($name) { global $entry, $useWysiwyg, $Cfg; $js_name = "'f_" . $name . "'"; // if opening an entry in wysiwyg, that was created in non-wysi // we might need to convert / textile / markdown it. if ($entry['convert_lb'] == 1) { $entry[$name] = strip_trailing_space(nl2br($entry[$name])); } else { if ($entry['convert_lb'] == 2) { list($tags, $entry[$name]) = translate_tags($entry[$name]); $entry[$name] = pivot_textile($entry[$name]); $entry[$name] = untranslate_tags($tags, $entry[$name]); } else { if ($entry['convert_lb'] == 3 || $entry['convert_lb'] == 4) { list($tags, $entry[$name]) = translate_tags($entry[$name]); $entry[$name] = pivot_markdown($entry[$name], $entry['convert_lb']); $entry[$name] = untranslate_tags($tags, $entry[$name]); } } } if (function_exists("pre_editor_wysi")) { // If the pre_editor_wysi hook is present.. pre_editor_wysi("f_" . $name . "_text", addltgt($entry[$name])); } else { if (!isset($entry[$name]) || strlen(strip_tags($entry[$name])) < 2) { $entry[$name] = "<p></p>"; } // Just use the standard wysi editor include "includes/editor/edit_menu.php"; echo "<iframe id={$js_name} name={$js_name} width='99%' height='160' marginwidth='4' marginheight='4' frameborder='0' style='border: 1px #cccccc solid; background-color:#FFF;' class='input' />If you can read this, the editor is not initiaised. You can try doing that now by clicking the icon with the little lightning arrow in the buttons-bar. If that does not work, you should set the 'use wysiwyg editor' in your 'My Info' to 'no'.</iframe>"; echo "<br /><br /><textarea class='input hidden' cols='60' rows=1 id='f_" . $name . "_text' name='f_" . $name . "_text' style='width:98%;'>" . addltgt($entry[$name]) . "</textarea>\n\n"; // enable the wysiwyg for editing.. echo "<script language='javascript' type='text/javascript'>\nsetTimeout( \"enable_edit({$js_name}, 'f_" . $name . "_text')\" , 10);\n</script>"; } }
/** * Parsing intro or body */ function parse_intro_or_body($text, $strip = "") { global $db, $Weblogs, $Current_weblog; $output = $text; if ($strip == "strip") { $output = strip_tags($output, "<a><b><i><u><embed><strong><ol><li><ul>"); } $output = parse_step4($output); /* text processing: nl2br, Textile or Markdown/SmartyPants We ensure that newlines aren't converted to br elements in script blocks - currently handling PHP and JavaScript. More exclusions will/can be added. */ // Use the ACK (006) ASCII symbol to replace all script elements temporarily $output = str_replace("", "", $output); $regexp = "#(<script[ >].*?</script>)|(<\\?php\\s.*?\\?>)#is"; preg_match_all($regexp, $output, $scripts); $output = preg_replace($regexp, "", $output); if ($db->entry['convert_lb'] == 1) { $output = strip_trailing_space(nl2br($output)); } else { if ($db->entry['convert_lb'] == 2) { $output = pivot_textile($output); } else { if ($db->entry['convert_lb'] == 3 || $db->entry['convert_lb'] == 4) { $output = pivot_markdown($output, $db->entry['convert_lb']); } } } // Put captured scripts back into the output foreach ($scripts[0] as $script) { $output = preg_replace("//", $script, $output, 1); } // targetblank if ($Weblogs[$Current_weblog]['target_blank'] > 0) { $output = targetblank($output); } // emoticons.. if ($Weblogs[$Current_weblog]['emoticons'] == 1) { $output = emoticonize($output); } // There's a silly quirk in TinyMCE, that prevents transparent Flash. We // need to fix this, to make Youtube videos work properly. $output = str_replace("<param name=\"wmode\" value=\"\" />", "<param name=\"wmode\" value=\"transparent\" />", $output); $output = str_replace(" wmode=\"\" ", " wmode=\"transparent\" ", $output); return tidy_html($output); }
/** * The screen you'll see after submitting an entry. It stores the entry, updates the indices (pivot's * content indices, and the search index), rebuilds the frontpage and XML & Atom feeds, and then it * displays a list of the latest entries. * */ function entrysubmit_screen() { global $db, $config_array, $Pivot_Vars, $entry, $Cfg, $Users, $Paths, $Weblogs, $filtered_words; // check against unauthorised direct access. check_csrf(); $db = new db(); $entry = get_entry_from_post(); if (!$entry['title'] == "" || !$entry['introduction'] == "" || !$entry['user'] == "") { // in this part, we remove the entry from the categories in which // the current user is not allowed to post entries foreach ($entry['category'] as $my_cat) { $allowed = explode("|", $Cfg['cat-' . $my_cat]); if (in_array($Pivot_Vars['user'], $allowed)) { $allowed_cats[] = $my_cat; } else { $message .= '<br />'; $message .= sprintf(lang('entries', 'entry_catnopost'), $m_cat); debug("not in category: " . $my_cat); } } $entry['category'] = $allowed_cats; $db->set_entry($entry); if ($db->save_entry(TRUE)) { $message = sprintf(lang('entries', 'entry_saved_ok') . $message, '<i>' . trimtext($entry['title'], 25) . '</i>'); } else { $message = sprintf(lang('entries', 'entry_saved_ok'), '<i>' . trimtext($entry['title'], 25) . '</i>'); } // only trigger the ping if it's a new entry.. if ($entry['code'] == ">" && $entry['status'] == "publish") { $ping = TRUE; } else { $ping = FALSE; } // only notify if entry is published, and is either new or status changed to publish. if ($entry['status'] == "publish") { if ($entry['code'] == ">" || $entry['oldstatus'] != "publish") { $notified = notify_new('entry', $db->entry); $notified = "<br /><br />" . $notified; } } // if the global index as they are made var is set - can continue if ('1' == $Cfg['search_index']) { /* 2004/10/16 =*=*= JM an entry should only be indexed if both are true: - 'publish'==$entry['status'] - current date is at least equal to $entry['publish_date'] I lie, there is another case... it is conceivable that this is a timed publish AND the time has come I will leave this to timed publish routines - if I can find them... -> pvLib ... it's flagged and of course, providing that there is at least one category where it would be indexed... something else that can't be tested... if the user changes a normal publish to a timed-publish, or puts on hold when it was previously normal. user should reindex in this case */ // check status and date if ('publish' == $entry['status'] || 'timed' == $entry['status'] && $entry['publish_date'] <= date('Y-m-d-H-i')) { // categories... if (can_search_cats(cfg_cat_nosearchindex(), $entry['category'])) { include_once 'modules/module_search.php'; update_index($db->entry); debug('update search index: ' . $db->entry['code']); } } } // perhaps send a trackback ping. if ($Pivot_Vars['tb_url'] != "" && $entry['status'] == "publish") { debug("tburl: " . $Pivot_Vars['tb_url']); require_once 'includes/send_trackback.php'; $weblogs = find_weblogs_with_cat($db->entry['category']); if (isset($Weblogs[$weblogs[0]])) { $my_url = $Paths['host'] . make_filelink($db->entry['code'], $weblogs[0], ''); $weblog_title = $Weblogs[$weblogs[0]]['name']; debug("TRACKBACK ping: {$my_url}"); $message .= '<br />'; $message .= sprintf(lang('entries', 'entry_ping_sent'), $Pivot_Vars['tb_url']); $tb_urls = explode("\n", $Pivot_Vars['tb_url']); // make the contents of what to send with the trackback.. $tb_contents = parse_step4($entry['introduction']); if ($Pivot_Vars['convert_lb'] == 2) { $tb_contents = pivot_textile($tb_contents); } else { if ($Pivot_Vars['convert_lb'] == 3 || $Pivot_Vars['convert_lb'] == 4) { $tb_contents = pivot_markdown($tb_contents, $Pivot_Vars['convert_lb']); } } $tb_contents = trimtext(strip_tags($tb_contents), 255); foreach ($tb_urls as $tb_url) { $tb_url = trim($tb_url); if (isurl($tb_url)) { trackback_send($Pivot_Vars['tb_url'], $my_url, $entry['title'], $weblog_title, $tb_contents); } } } } // Update the tags for this entry if it's published and remove the old tags if not if ($db->entry['status'] == 'publish') { writeTags($db->entry['keywords'], $_POST['f_keywords_old'], $db->entry['code']); } else { deleteTags($_POST['f_keywords_old'], $db->entry['code']); } } generate_pages($db->entry['code'], TRUE, TRUE, TRUE, $ping); entries_screen($message . $notified); }
/** * Formats comments according the settings for the current weblog. * * We strip _all_ tags except <b> and <i> and after that * we convert everything that looks like a url or mail-address * to the equivalent link (if enabled). Using textile if enabled. * * @param string $text * @return string */ function comment_format($text) { global $Cfg, $Weblogs, $Current_weblog, $Paths; $text = trim(strip_tags($text, '<b>,<i>,<em>,<strong>')); $text = preg_replace('/<([^\\s>]*)(\\s[^<]*)>/i', "<\\1>", $text); // did user request '_blank' target rerouting? if (1 == $Weblogs[$Current_weblog]['target_blank']) { $target = ' target="_blank"'; } else { $target = ''; } if (1 == $Weblogs[$Current_weblog]['comment_textile']) { if (1 == $Weblogs[$Current_weblog]['comment_texttolinks']) { // the old-style automatic links are converted to textile links. $text = preg_replace("/([ \t]|^)www\\./mi", "\\1http://www.", $text); $text = preg_replace("#([ \t]|^)(http://[^ )\r\n]+)#mi", "\\1\"\\2\":\\2", $text); // Fix wrongfully matched images.. $text = preg_replace('/"http:\\/\\/([-a-z0-9_.\\/]*)!":http:\\/\\/([-a-z0-9_.\\/]*)!/Ui', '!http://\\1!', $text); $text = eregi_replace("([-a-z0-9_]+(\\.[_a-z0-9-]+)*@([a-z0-9-]+(\\.[a-z0-9-]+)+))", "<a href=\"mailto:\\1\">\\1</A>", $text); } $text = pivot_textile($text); // when textiled, we only want <br />, and not <p>.. Clean <p> and </p> $text = preg_replace("/<br \\/>/sUi", "", $text); $text = preg_replace("/<p([^>]*)>/sUi", "", $text); $text = preg_replace("/<\\/p>/sUi", "", $text); // make textile also obey the target setting $text = eregi_replace('<a href="(http://[^"]+)">([^<]+)</a>', "<a href=\"\\1\"{$target}>[[\\2]]</a>", $text); $text = eregi_replace('<a href="(https://[^"]+)">([^<]+)</a>', "<a href=\"\\1\"{$target}>[[\\2]]</a>", $text); $text = eregi_replace('<a href="(ftp://[^"]+)">([^<]+)</a>', "<a href=\"\\1\"{$target}>[[\\2]]</a>", $text); $text = nl2br(trim($text)); } else { if (1 == $Weblogs[$Current_weblog]['comment_texttolinks']) { $text = preg_replace("#([ \t]|^)www\\.#mi", "\\1http://www.", $text); $text = preg_replace("#([ \t]|^)ftp\\.#mi", "\\1ftp://ftp.", $text); $text = preg_replace("#([ \t]|^)(http://[^ )\r\n]+)#mi", "\\1<a href=\"\\2\"{$target}>[[\\2]]</a>", $text); $text = preg_replace("#([ \t]|^)(https://[^ )\r\n]+)#mi", "\\1<a href=\"\\2\"{$target}>[[\\2]]</a>", $text); $text = preg_replace("#([ \t]|^)(ftp://[^ )\r\n]+)#mi", "\\1<a href=\"\\2\"{$target}>[[\\2]]</a>", $text); preg_match_all("|\\[\\[(.*)\\]\\]|U", $text, $match, PREG_PATTERN_ORDER); // do we need to do changes? if (is_array($match) && count($match) > 0) { foreach ($match[1] as $url) { $url2 = str_replace('@', '%40', $url); $text = str_replace($url, $url2, $text); } } $text = eregi_replace("([-a-z0-9_]+(\\.[_a-z0-9-]+)*@([a-z0-9-]+(\\.[a-z0 -9-]+)+))", "<a href=\"mailto:\\1\">\\1</a>", $text); // now change the '@' back... $text = str_replace('%40', '@', $text); } } // If not using Textile convert linebreaks to HTML breaks. if (1 != $Weblogs[$Current_weblog]['comment_textile']) { $text = nl2br(trim($text)); } // then make long urls into short urls, with correct link.. preg_match_all("|\\[\\[(.*)\\]\\]|U", $text, $match, PREG_PATTERN_ORDER); foreach ($match[1] as $url) { if (strlen($url) > 40) { $s_url = substr($url, 0, 40) . '..'; } else { $s_url = $url; } $text = str_replace('[[' . $url . ']]', $s_url, $text); } // perhaps redirect the link.. if (isset($Weblogs[$Current_weblog]['lastcomm_redirect']) && 1 == $Weblogs[$Current_weblog]['lastcomm_redirect']) { //$text = str_replace( 'href="http://','href="'.$Paths['pivot_url'].'includes/re.php?http://',$text ); $text = preg_replace("#<a href=(\"|')([^>\n]+)\\1([^<>]*)>(.*)</a>#iUs", "<a href=\"\\2\" \\3 rel='nofollow'>\\4</a>", $text); } if ($Weblogs[$Current_weblog]['emoticons'] == 1) { $text = emoticonize($text); } // If magic_quotes_gpc is not set, we need to strip slashes.. if (!get_magic_quotes_gpc()) { $text = stripslashes($text); } return $text; }