home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / misc / forward_page.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  8.7 KB  |  286 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Forward topic to a friend module
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 21st March 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Forward;
  26.  
  27. class Forward {
  28.  
  29.     var $output    = "";
  30.     var $base_url  = "";
  31.     var $html      = "";
  32.  
  33.     var $forum     = array();
  34.     var $topic     = array();
  35.     var $category  = array();
  36.  
  37.     
  38.     /***********************************************************************************/
  39.     //
  40.     // Our constructor, load words, load skin, print the topic listing
  41.     //
  42.     /***********************************************************************************/
  43.     
  44.     function Forward() {
  45.     
  46.     
  47.         global $ibforums, $DB, $std, $print, $skin_universal;
  48.         
  49.         require "./Skin/".$ibforums->skin_id."/skin_emails.php";
  50.  
  51.         //-------------------------------------
  52.         // Compile the language file
  53.         //-------------------------------------
  54.         
  55.         $ibforums->lang = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id);
  56.  
  57.         $this->html     = new skin_emails();
  58.         
  59.         //-------------------------------------
  60.         // Check the input
  61.         //-------------------------------------
  62.         
  63.         $ibforums->input['t'] = $std->is_number($ibforums->input['t']);
  64.         $ibforums->input['f'] = $std->is_number($ibforums->input['f']);
  65.         
  66.         if ($ibforums->input['t'] < 0 or $ibforums->input['f'] < 0)
  67.         {
  68.             $std->Error( array( LEVEL => 1, MSG => 'missing_files') );
  69.         }
  70.         
  71.         //-------------------------------------
  72.         // Get the forum info based on the forum ID, get the category name, ID, and get the topic details
  73.         //-------------------------------------
  74.         
  75.        $DB->query("SELECT t.*, f.name as forum_name, f.id as forum_id, f.read_perms, f.reply_perms, f.start_perms, f.allow_poll, f.posts as forum_posts, f.topics as forum_topics, f.use_attach, c.name as cat_name, c.id as cat_id FROM ibf_topics t, ibf_forums f , ibf_categories c where t.tid='".$ibforums->input[t]."' and f.id = t.forum_id and f.category=c.id");
  76.         
  77.         $this->topic = $DB->fetch_row();
  78.         
  79.         $this->forum = array( 'id'           => $this->topic['forum_id']          ,
  80.                               'name'         => $this->topic['forum_name']        ,
  81.                               'posts'        => $this->topic['forum_posts']       ,
  82.                               'topics'       => $this->topic['forum_topics']      ,
  83.                               'read_perms'   => $this->topic['read_perms']        ,
  84.                               'allow_poll'   => $this->topic['allow_poll']        ,
  85.                               'use_attach'   => $this->topic['use_attach']
  86.                             );
  87.                             
  88.         $this->category = array( 'name'   => $this->topic['cat_name'],
  89.                                  'id'     => $this->topic['cat_id']  ,
  90.                                );
  91.         
  92.         //-------------------------------------
  93.         // Error out if we can not find the forum
  94.         //-------------------------------------
  95.         
  96.         if (!$this->forum['id'])
  97.         {
  98.             $std->Error( array( LEVEL => 1, MSG => 'missing_files') );
  99.         }
  100.         
  101.         //-------------------------------------
  102.         // Error out if we can not find the topic
  103.         //-------------------------------------
  104.         
  105.         if (!$this->topic['tid'])
  106.         {
  107.             $std->Error( array( LEVEL => 1, MSG => 'missing_files') );
  108.         }
  109.         
  110.         $this->base_url    = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  111.         
  112.         $this->base_url_NS = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
  113.         
  114.         //-------------------------------------
  115.         // Check viewing permissions, private forums,
  116.         // password forums, etc
  117.         //-------------------------------------
  118.         
  119.         if (! $ibforums->member['id'] )
  120.         {
  121.             $std->Error( array( LEVEL => 1, MSG => 'no_guests') );
  122.         }
  123.         
  124.         $bad_entry = $this->check_access();
  125.         
  126.         if ($bad_entry == 1)
  127.         {
  128.             $std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
  129.         }      
  130.         
  131.         // What to do?
  132.         
  133.         if ($ibforums->input['CODE'] == '01')
  134.         {
  135.             $this->send_email();
  136.         }
  137.         else
  138.         {
  139.             $this->show_form();
  140.         }
  141.  
  142.         
  143.     }
  144.     
  145.  
  146.     function send_email() {
  147.         global $std, $ibforums, $DB, $print;
  148.         
  149.         require "./sources/lib/emailer.php";
  150.         
  151.         $this->email = new emailer();
  152.         
  153.         $lang_to_use = 'en';
  154.         
  155.         $DB->query("SELECT lid, ldir, lname FROM ibf_languages");
  156.         
  157.         while ( $l = $DB->fetch_row() )
  158.         {
  159.             if ($ibforums->input['lang'] == $l['ldir'])
  160.             {
  161.                 $lang_to_use = $l['ldir'];
  162.             }
  163.         }
  164.         
  165.         $check_array = array ( 'to_name'   =>  'stf_no_name',
  166.                                'to_email'  =>  'stf_no_email',
  167.                                'message'   =>  'stf_no_msg',
  168.                                'subject'   =>  'stf_no_subject'
  169.                              );
  170.                              
  171.         foreach ($check_array as $input => $msg)
  172.         {
  173.             if (empty($ibforums->input[$input]))
  174.             {
  175.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => $msg) );
  176.             }
  177.         }
  178.         
  179.         $to_email = $std->clean_email($ibforums->input['to_email']);
  180.         
  181.         if (! $to_email )
  182.         {
  183.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_email' ) );
  184.         }
  185.         
  186.         
  187.         $this->email->get_template("forward_page", $lang_to_use);
  188.             
  189.         $this->email->build_message( array(
  190.                                             'THE_MESSAGE'     => str_replace( "<br>", "\n", $ibforums->input['message'] ),
  191.                                             'TO_NAME'         => $ibforums->input['to_name'],
  192.                                             'FROM_NAME'       => $ibforums->member['name'],
  193.                                           )
  194.                                     );
  195.                                     
  196.         $this->email->subject = $ibforums->input['subject'];
  197.         $this->email->to      = $ibforums->input['to_email'];
  198.         $this->email->from    = $ibforums->member['email'];
  199.         $this->email->send_mail();
  200.         
  201.         $print->redirect_screen( $ibforums->lang['redirect'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
  202.     
  203.     }
  204.     
  205.     
  206.     
  207.     
  208.     
  209.     function show_form() {
  210.         global $std, $ibforums, $DB, $print, $root_path;
  211.         
  212.         require $root_path."lang/".$ibforums->lang_id."/email_content.php";
  213.         
  214.         $ibforums->lang['send_text'] = $EMAIL['send_text'];
  215.         
  216.         $lang_array = unserialize(stripslashes($ibforums->vars['languages']));
  217.         
  218.         $lang_select = "<select name='lang' class='forminput'>\n";
  219.         
  220.         $DB->query("SELECT lid, ldir, lname FROM ibf_languages");
  221.         
  222.         while ( $l = $DB->fetch_row() )
  223.         {
  224.             $lang_select .= $l['ldir'] == $ibforums->member['language'] ? "<option value='{$l['ldir']}' selected>{$l['lname']}</option>"
  225.                                                                         : "<option value='{$l['ldir']}'>{$l['lname']}</option>";
  226.         }
  227.          
  228.          $lang_select .= "</select>";
  229.         
  230.         $ibforums->lang['send_text'] = preg_replace( "/<#THE LINK#>/" , $this->base_url_NS."?act=ST&f=".$this->forum['id']."&t=".$this->topic['tid'], $ibforums->lang['send_text'] );
  231.         $ibforums->lang['send_text'] = preg_replace( "/<#USER NAME#>/", $ibforums->member['name'], $ibforums->lang['send_text'] );
  232.         
  233.         $this->output = $this->html->forward_form( $this->topic['title'], $ibforums->lang ['send_text'], $lang_select  );
  234.         
  235.         $this->page_title  = $ibforums->lang['title'];
  236.         
  237.         $this->nav         = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",  "<a href='".$this->base_url."&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>", $ibforums->lang['title'] );
  238.         
  239.         $print->add_output("$this->output");
  240.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
  241.         
  242.     }
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250. //+----------------------------------------------------------------------------------
  251.     
  252.     
  253.     function check_access() {
  254.         global $ibforums, $HTTP_COOKIE_VARS;
  255.         
  256.         $return = 1;
  257.         
  258.         $this->m_group = $ibforums->member['mgroup'];
  259.         
  260.         if ($this->forum['read_perms'] == '*') {
  261.             $return = 0;
  262.         }
  263.         else if (preg_match( "/(^|,)$this->m_group(,|$)/", $this->forum['read_perms'] ) ) {
  264.             $return = 0;
  265.         }
  266.         
  267.         if ($this->forum['password']) {
  268.             if ($HTTP_COOKIE_VARS[ $ibforums->vars['cookie_id'].'iBForum'.$this->forum['id'] ] == $this->forum['password']) {
  269.                 $return = 0;
  270.             } else {
  271.                 $return = 1;
  272.             }
  273.         }
  274.         
  275.         return $return;
  276.     
  277.     }
  278. }
  279.  
  280. ?>
  281.  
  282.  
  283.  
  284.  
  285.  
  286.