function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if (!$this->pre_save_blogtext($doquery)) { $this->presave_called = false; return false; } /* perform Akismet on new comments that would be visible */ if (!$this->condition AND $this->fetch_field('state') == 'visible' AND !$this->info['skip_akismet']) { $akismet_url = $this->registry->options['bburl'] . '/blog.php'; if (!empty($this->registry->options['vb_antispam_key'])) { // global key, use the global URL aka blog.php $akismet_key = $this->registry->options['vb_antispam_key']; } else { $akismet_key = $this->info['akismet_key']; $akismet_url = $this->registry->options['bburl'] . '/blog.php?u=' . $this->fetch_field('bloguserid'); } if (!empty($akismet_key)) { // these are taken from the Akismet API: http://akismet.com/development/api/ $akismet_data = array(); $akismet_data['user_ip'] = $this->fetch_field('ipaddress'); $akismet_data['user_agent'] = USER_AGENT; $akismet_data['comment_type'] = 'comment'; $akismet_data['comment_author'] = $this->fetch_field('username'); $akismet_data['comment_content'] = $this->fetch_field('pagetext'); if (verify_akismet_status($akismet_key, $akismet_url, $akismet_data) == 'spam') { $this->set('state', 'moderation'); } } } $return_value = true; ($hook = vBulletinHook::fetch_hook('blog_textdata_presave')) ? eval($hook) : false; $this->presave_called = $return_value; return $return_value; }
function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if (!$this->condition) { if (!($blogid = $this->fetch_field('blogid'))) { global $vbphrase; $this->error('invalidid', $vbphrase['blog'], $this->registry->options['contactuslink']); return false; } if (!($url = $this->fetch_field('url'))) { $this->error('no_url_specified'); return false; } if (!$this->fetch_field('state')) { $this->set('state', 'moderation'); } if (!$this->fetch_field('dateline')) { $this->set('dateline', TIMENOW); } if (!$this->fetch_field('title') OR !$this->fetch_field('snippet')) { require_once(DIR . '/includes/functions_file.php'); if ($bodyresult = fetch_body_request($url, 100000)) { if (preg_match('#<head[^>]*>.*<title>(.*)</title>.*</head>.*<body(.*?)#siU', $bodyresult, $matches)) { $body =& $matches[2]; if (!$this->fetch_field('title')) { $this->set('title', $matches[1]); } else { $this->error('invalid_title_specified'); return false; } if (!$this->fetch_field('snippet')) { if (preg_match('#(<a[^>]+href=(\'|")' . preg_quote($this->registry->options['bburl'], '#') . '\/blog(?:_callback)?.php\?b(?:logid)?=' . $blogid . '\\2[^>]*>(.*)</a>)#siU', $body, $matches)) { $hash = md5(TIMENOW . SCRIPTPATH . SESSION_IDHASH . SESSION_HOST . vbrand(1, 1000000)); $body = str_replace($matches[1], "<$hash>" . $matches[3] . "</$hash>", $body); $body = strip_tags($body, "<$hash>"); $start = strpos($body, "<$hash>" . $matches[3] . "</$hash>"); $length = strlen("<$hash>" . $matches[3] . "</$hash>"); $snippet = str_replace( array( "<$hash>", "</$hash>", ), array( '', '', ), trim(substr($body, $start - 100, $length + 200)) ); $this->set('snippet', $snippet); } else { $this->error('could_not_parse_link_href_from_link'); return false; } } return true; } else { $this->error('failed_to_parse_html_body'); return false; } } else { $this->error('failed_to_retrieve_body_' . $url); return false; } } if ($this->fetch_field('state') == 'visible' AND !$this->info['skip_akismet']) { $akismet_url = $this->registry->options['bburl'] . '/blog.php'; $permalink = $this->registry->options['bburl'] . '/blog.php?b= ' . $this->fetch_field('blogid'); if (!empty($this->registry->options['vb_antispam_key'])) { // global key, use the global URL aka blog.php $akismet_key = $this->registry->options['vb_antispam_key']; } else { $akismet_key = $this->info['akismet_key']; $akismet_url = $this->registry->options['bburl'] . '/blog.php?u=' . $this->fetch_field('userid'); } if (!empty($akismet_key)) { // these are taken from the Akismet API: http://akismet.com/development/api/ $akismet_data = array(); $akismet_data['user_ip'] = IPADDRESS; $akismet_data['user_agent'] = USER_AGENT; $akismet_data['permalink'] = $permalink; $akismet_data['comment_type'] = 'trackback'; $akismet_data['comment_author_url'] = $this->fetch_field('url'); $akismet_data['comment_content'] = $this->fetch_field('snippet'); if (verify_akismet_status($akismet_key, $akismet_url, $akismet_data) == 'spam') { $this->set('state', 'moderation'); } } } } $return_value = true; ($hook = vBulletinHook::fetch_hook('blog_trackbackdata_presave')) ? eval($hook) : false; $this->presave_called = $return_value; return $return_value; }