$Date: 2006-01-11 22:47:48 +0000 (Wed, 11 Jan 2006) $
| > $Revision: 122 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > Forward topic to a friend module
| > Module written by Matt Mecham
| > Date started: 21st March 2002
|
| > Module Version Number: 1.0.0
| > DBA Checked: Mon 24th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
{
print "
Некорректный адрес
Вы не имеете доступа к этому файлу напрямую. Если вы недавно обновляли форум, вы должны обновить все соответствующие файлы.";
exit();
}
class forwardpage
{
var $ipsclass;
var $output = "";
var $base_url = "";
var $html = "";
var $forum = array();
var $topic = array();
var $category = array();
/*-------------------------------------------------------------------------*/
//
// Our constructor, load words, load skin, print the topic listing
//
/*-------------------------------------------------------------------------*/
function auto_run()
{
//-----------------------------------------
// Compile the language file
//-----------------------------------------
$this->ipsclass->load_language('lang_emails');
$this->ipsclass->load_template('skin_emails');
//-----------------------------------------
// Check the input
//-----------------------------------------
$this->ipsclass->input['t'] = intval($this->ipsclass->input['t']);
$this->ipsclass->input['f'] = intval($this->ipsclass->input['f']);
if ( !$this->ipsclass->input['t'] )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-----------------------------------------
// Get the topic details
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "tid=".intval($this->ipsclass->input['t']) ) );
$this->ipsclass->DB->simple_exec();
$this->topic = $this->ipsclass->DB->fetch_row();
$this->forum = $this->ipsclass->forums->forum_by_id[ $this->topic['forum_id'] ];
//-----------------------------------------
// Error out if we can not find the forum
//-----------------------------------------
if ( ! $this->forum['id'] )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-----------------------------------------
// Error out if we can not find the topic
//-----------------------------------------
if (!$this->topic['tid'])
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$this->base_url = $this->ipsclass->base_url;
$this->base_url_NS = "{$this->ipsclass->vars['board_url']}/index.{$this->ipsclass->vars['php_ext']}";
//-----------------------------------------
// Check viewing permissions, private forums,
// password forums, etc
//-----------------------------------------
if (! $this->ipsclass->member['id'] )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'no_guests') );
}
$this->ipsclass->forums->forums_check_access( $this->forum['id'] );
//-----------------------------------------
// What to do?
//-----------------------------------------
if ($this->ipsclass->input['CODE'] == '01')
{
$this->send_email();
}
else
{
$this->show_form();
}
}
function send_email()
{
require ROOT_PATH."sources/classes/class_email.php";
$this->email = new emailer();
$this->email->ipsclass =& $this->ipsclass;
$this->email->email_init();
$lang_to_use = 'ru';
$this->ipsclass->DB->query("SELECT lid, ldir, lname FROM ibf_languages");
while ( $l = $this->ipsclass->DB->fetch_row() )
{
if ($this->ipsclass->input['lang'] == $l['ldir'])
{
$lang_to_use = $l['ldir'];
}
}
$check_array = array ( 'to_name' => 'stf_no_name',
'to_email' => 'stf_no_email',
'message' => 'stf_no_msg',
'subject' => 'stf_no_subject'
);
foreach ($check_array as $input => $msg)
{
if (empty($this->ipsclass->input[$input]))
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => $msg) );
}
}
$to_email = $this->ipsclass->clean_email($this->ipsclass->input['to_email']);
if (! $to_email )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_email' ) );
}
$this->email->get_template("forward_page", $lang_to_use);
$this->email->build_message( array(
'THE_MESSAGE' => str_replace( "
", "\n", $this->ipsclass->input['message'] ),
'TO_NAME' => $this->ipsclass->input['to_name'],
'FROM_NAME' => $this->ipsclass->member['members_display_name'],
)
);
$this->email->subject = $this->ipsclass->input['subject'];
$this->email->to = $this->ipsclass->input['to_email'];
$this->email->from = $this->ipsclass->member['email'];
$this->email->send_mail();
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['redirect'], "showtopic=".$this->topic['tid']."&st=".$this->ipsclass->input['st'] );
}
function show_form()
{
require ROOT_PATH."cache/lang_cache/".$this->ipsclass->lang_id."/lang_email_content.php";
$this->ipsclass->lang['send_text'] = $lang['send_text'];
$lang_array = unserialize(stripslashes($this->ipsclass->vars['languages']));
$lang_select = "";
$this->ipsclass->lang['send_text'] = preg_replace( "/<#THE LINK#>/" , $this->base_url_NS."?act=ST&f=".$this->forum['id']."&t=".$this->topic['tid'], $this->ipsclass->lang['send_text'] );
$this->ipsclass->lang['send_text'] = preg_replace( "/<#USER NAME#>/", $this->ipsclass->member['members_display_name'], $this->ipsclass->lang['send_text'] );
$this->output = $this->ipsclass->compiled_templates['skin_emails']->forward_form( $this->topic['title'], $this->ipsclass->lang['send_text'], $lang_select );
$this->page_title = $this->ipsclass->lang['title'];
$this->nav = array ( "{$this->forum['name']}", "topic['tid']}'>{$this->topic['title']}", $this->ipsclass->lang['title'] );
$this->ipsclass->print->add_output("$this->output");
$this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
//-----------------------------------------
function check_access()
{
$return = 1;
if ( $this->ipsclass->check_perms($this->forum['read_perms']) == TRUE )
{
$return = 0;
}
if ($this->forum['password'])
{
if ($_COOKIE[ $this->ipsclass->vars['cookie_id'].'iBForum'.$this->forum['id'] ] == $this->forum['password']) {
$return = 0;
} else {
$return = 1;
}
}
return $return;
}
}
?>