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); }
/** * Updates a post. * * @param string $uid * @param string $postid * @param string $title * @param string $content * @param array $categories * @return void */ function pivot_update_post($uid, $postid, $title, $content, $categories = '') { global $db, $conversion_method, $body_separator; $oldentry = $db->read_entry($postid); $entry['code'] = $postid; $entry['date'] = $oldentry['date']; list($pivotintro, $pivotbody) = explode($body_separator, strip_trailing_space(stripslashes($content))); $entry['introduction'] = $pivotintro; $entry['body'] = $pivotbody; $entry['introduction'] = tidy_html($entry['introduction'], TRUE); $entry['body'] = tidy_html($entry['body'], TRUE); if (empty($categories)) { $entry['category'] = $oldentry['category']; } else { $entry['category'] = $categories; } $entry['publish_date'] = $oldentry['publish_date']; $entry['edit_date'] = date("Y-m-d-H-i", get_current_date()); $entry['title'] = strip_trailing_space(stripslashes($title)); $entry['subtitle'] = $oldentry['subtitle']; $entry['user'] = $uid; $entry['convert_lb'] = $conversion_method; $entry['status'] = "publish"; $entry['allow_comments'] = 1; $entry['keywords'] = $oldentry['keywords']; $entry['vialink'] = $oldentry['vialink']; $entry['viatitle'] = $oldentry['viatitle']; $db->set_entry($entry); $db->save_entry(TRUE); generate_pages($db->entry['code'], TRUE, TRUE, TRUE, FALSE); }
// check if we are TEH REG USER.. if (strlen($_COOKIE['piv_reguser']) > 4) { list($reg_name, $reg_hash) = explode("|", $_COOKIE['piv_reguser']); debug("reg: {$reg_name}, {$reg_hash}"); if (check_user_hash($reg_name, $reg_hash) && $reg_name == $Pivot_Vars['piv_name']) { $registered = 1; } } // If magic_quotes_gpc is set, we need to strip slashes.. if (get_magic_quotes_gpc()) { $Pivot_Vars['piv_name'] = stripslashes($Pivot_Vars['piv_name']); $Pivot_Vars['piv_email'] = stripslashes($Pivot_Vars['piv_email']); $Pivot_Vars['piv_url'] = stripslashes($Pivot_Vars['piv_url']); $Pivot_Vars['piv_comment'] = stripslashes($Pivot_Vars['piv_comment']); } $comment_text = strip_trailing_space($Pivot_Vars['piv_comment']); $comment_text = str_replace("\r\n", "\n", $comment_text); // CRLF(Win) to LF $comment_text = str_replace("\r", "\n", $comment_text); // CR(Mac) to LF $my_comment = array('name' => entify($Pivot_Vars['piv_name']), 'email' => entify($Pivot_Vars['piv_email']), 'url' => entify($Pivot_Vars['piv_url']), 'ip' => $Pivot_Vars['REMOTE_ADDR'], 'date' => format_date("", "%year%-%month%-%day%-%hour24%-%minute%"), 'comment' => $comment_text, 'registered' => $registered, 'notify' => $Pivot_Vars['piv_notify'], 'discreet' => $Pivot_Vars['piv_discreet'], 'moderate' => $Cfg['moderate_comments'] == 1); //here we do a check to prevent double entries... $duplicate = FALSE; if (isset($entry['comments']) && count($entry['comments']) > 0) { foreach ($entry['comments'] as $loop_comment) { $diff = 1 / (min(strlen($loop_comment['comment']), 200) / (levenshtein(substr($loop_comment['comment'], 0, 200), substr($my_comment['comment'], 0, 200)) + 1)); if ($diff < 0.25 && $loop_comment['ip'] == $my_comment['ip']) { $duplicate = TRUE; break; } }
/** * When an entry is created or edited, it's passed in $_POST ($Pivot_vars). * This function gets all the variables and returns it as an $entry array * * @return array */ function get_entry_from_post() { global $Users, $Pivot_Vars, $useWysiwyg, $db, $Cfg; if (isset($Pivot_Vars['f_code']) && $Pivot_Vars['f_code'] != "") { $entry = $db->read_entry($Pivot_Vars['f_code']); $entry['oldstatus'] = $entry['status']; } else { $entry['code'] = ">"; } if (strlen($Pivot_Vars['f_createdate_1']) > 7 && $Pivot_Vars['f_createdate_1'] != "00-00-0000") { // if the date is filled, we try to parse it.. $entry['date'] = fix_date($Pivot_Vars['f_createdate_1'], $Pivot_Vars['f_createdate_2']); } else { // otherwise we'll just assume 'now'. $entry['date'] = date("Y-m-d-H-i", get_current_date()); } if (isset($Pivot_Vars['f_introduction_text'])) { $entry['introduction'] = strip_trailing_space($Pivot_Vars['f_introduction_text']); $entry['body'] = strip_trailing_space($Pivot_Vars['f_body_text']); } else { $entry['introduction'] = strip_trailing_space($Pivot_Vars['f_introduction']); $entry['body'] = strip_trailing_space($Pivot_Vars['f_body']); } // If magic_quotes_gpc is set, we need to strip slashes.. if (get_magic_quotes_gpc()) { $entry['introduction'] = stripslashes($entry['introduction']); $entry['body'] = stripslashes($entry['body']); $Pivot_Vars['f_title'] = stripslashes($Pivot_Vars['f_title']); $Pivot_Vars['f_subtitle'] = stripslashes($Pivot_Vars['f_subtitle']); } $entry['introduction'] = tidy_html($entry['introduction'], TRUE); $entry['body'] = tidy_html($entry['body'], TRUE); $entry['category'] = @$Pivot_Vars['f_catmult']; $entry['publish_date'] = fix_date($Pivot_Vars['f_publishdate_1'], $Pivot_Vars['f_publishdate_2']); $entry['edit_date'] = date("Y-m-d-H-i"); $entry['title'] = strip_trailing_space($Pivot_Vars['f_title']); $entry['subtitle'] = strip_trailing_space($Pivot_Vars['f_subtitle']); $entry['user'] = $Pivot_Vars['f_user']; $entry['convert_lb'] = $Pivot_Vars['convert_lb']; $entry['status'] = $Pivot_Vars['f_status']; $entry['allow_comments'] = $Pivot_Vars['f_allowcomments']; $entry['vialink'] = strip_tags($Pivot_Vars['f_vialink']); $entry['viatitle'] = strip_tags($Pivot_Vars['f_viatitle']); // Only store the tb_url if we're not publishing. (because if we publish, we ping it, and forget it) if ($entry['status'] != "publish") { $entry['tb_url'] = strip_tags($Pivot_Vars['tb_url']); } else { if (isset($entry['tb_url'])) { unset($entry['tb_url']); } } // Gather all tags from introduction and body in keywords.. $tags = getTags(false, $entry['introduction'] . $entry['body'], strip_tags($Pivot_Vars['f_keywords'])); $entry['keywords'] = implode(", ", $tags); return $entry; }
// checking if IP address of trackbacking site is blocked if (ip_check_block($Pivot_Vars['REMOTE_ADDR'])) { debug("Blocked user from " . $Pivot_Vars['REMOTE_ADDR'] . " tried to trackback"); respondExit("Your IP-address has been blocked, so you are not" . " allowed to leave trackbacks on this site. We know IP-adresses can easily be faked," . " but it helps.", 1); } // Exit if no trackback (entry) ID is given if (!($Pivot_Vars['tb_id'] = mungeTbId($Pivot_Vars['tb_id']))) { respondExit(lang('trackback', 'noid'), 1); } // Open database $db = new db(); // Exit if non-existing ID supplied if (!$db->entry_exists($Pivot_Vars['tb_id'])) { respondExit('Non-existing ID', 1); } $my_trackback = array('name' => entify(urldecode(stripslashes($Pivot_Vars['blog_name']))), 'title' => entify(urldecode(stripslashes($Pivot_Vars['title']))), 'url' => urldecode($Pivot_Vars['url']), 'ip' => $Pivot_Vars['REMOTE_ADDR'], 'date' => format_date("", "%year%-%month%-%day%-%hour24%-%minute%"), 'excerpt' => strip_trailing_space(urldecode(stripslashes($Pivot_Vars['excerpt'])))); // Exit if no URL is given - need to know URL to foreign entry that // trackbacked us. if (empty($my_trackback['url'])) { respondExit(lang('trackback', 'nourl'), 1); } // load an entry $entry = $db->read_entry($Pivot_Vars['tb_id']); //here we do a check to prevent double entries... $duplicate = FALSE; if (isset($entry['trackbacks']) && count($entry['trackbacks']) > 0) { foreach ($entry['trackbacks'] as $loop_trackback) { $diff = 1 / (min(strlen($loop_trackback['excerpt']), 200) / (levenshtein(substr($loop_trackback['excerpt'], -200), substr($my_trackback['excerpt'], -200)) + 1)); if ($diff < 0.25 && $loop_trackback['ip'] == $my_trackback['ip']) { $duplicate = TRUE; }