/** * Returns article object * * @return Articles */ public function get_article() { if ($this->article === false) { class_exists('Articles') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'); $article_list = new Articles_list(); $this->article = $article_list->get_article_by_id($this->article_id); } return $this->article; }
function get_article_absolute_href() { if (!$this->article_obj) { require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; $al = new Articles_list(null, 'title,sefriendly,category_id'); $this->article_obj = $al->get_article_by_id($this->article_id); } if ($this->article_obj) { return $this->article_obj->get_absolute_href(); } }
function email_to_a_friend($article_id, $to, $bcc, $your_email, $message) { require_once VIVVO_FS_FRAMEWORK . 'PEAR/Mail.php'; if (!vivvo_hooks_manager::call('article_mail', array(&$article_id, &$to, &$bcc, &$your_email, &$message))) { return vivvo_hooks_manager::get_status(); } if (VIVVO_EMAIL_ENABLE == 1) { if (isset($_SESSION['vivvo']['email_to_friend_time']) && $_SESSION['vivvo']['email_to_friend_time'] + VIVVO_EMAIL_FLOOD_CHECK > VIVVO_START_TIME) { $this->set_error_code(2202); return false; } $article_list = new Articles_list(); $article = $article_list->get_article_by_id($article_id); $lang = vivvo_lang::get_instance(); if ($article !== false) { $to = strip_tags($to); $bcc = strip_tags($bcc); if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $your_email)) { $this->set_error_code(2032); return false; } if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $bcc)) { $bcc = ''; } if (VIVVO_EMAIL_SEND_BCC) { if ($bcc) { $bcc .= ', ' . VIVVO_EMAIL_SEND_BCC; } else { $bcc = VIVVO_EMAIL_SEND_BCC; } } if (VIVVO_EMAIL_SEND_CC) { $headers['Cc'] = VIVVO_EMAIL_SEND_CC; } if (preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $to)) { $body_template = new template(); $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_TO_A_FRIEND_BODY); $body_template->set_string_template($template_sting); $body_template->assign('article', $article); $body_template->assign('user_email_address', $your_email); $body_template->assign('message', $message); $body = $body_template->get_output() . "\n\n"; $headers['From'] = $your_email; $recipients = array(); $recipients[] = $to; if ($bcc != '') { $headers['Bcc'] = $bcc; } $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_TO_A_FRIEND_SUBJECT) . "?="; $headers['Content-Type'] = "text/plain; charset=UTF-8;"; if (VIVVO_EMAIL_SMTP_PHP == 1) { $mail_object = new Mail(); $mail_object->send($to, $headers, $body); } else { $mail_options['driver'] = 'smtp'; $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST; $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT; $mail_options['localhost'] = 'localhost'; if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') { $mail_options['auth'] = true; $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME; $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD; } else { $mail_options['auth'] = false; $mail_options['username'] = ''; $mail_options['password'] = ''; } $mail_object = Mail::factory('smtp', $mail_options); $mail_object->send($to, $headers, $body); } $article->set_emailed($article->emailed + 1); $this->_post_master->set_data_object($article); if ($this->_post_master->sql_update()) { $_SESSION['vivvo']['email_to_friend_time'] = time(); return true; } else { $this->set_error_code(2033); return false; } } else { $this->set_error_code(2034); return false; } } else { $this->set_error_code(2035); return false; } } }