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 / contact_member.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  9.6 KB  |  376 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. |   > ICQ / AIM / EMAIL functions
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 28th February 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Contact;
  26.  
  27. class Contact {
  28.  
  29.     var $output    = "";
  30.     var $base_url  = "";
  31.     var $html      = "";
  32.     
  33.     var $nav       = array();
  34.     var $page_title= "";
  35.     var $email     = "";
  36.  
  37.     /***********************************************************************************/
  38.     //
  39.     // Our constructor, load words, load skin
  40.     //
  41.     /***********************************************************************************/
  42.     
  43.     function Contact() {
  44.     
  45.         global $ibforums, $DB, $std, $print, $skin_universal;
  46.         
  47.         
  48.         // What to do?
  49.         
  50.         switch($ibforums->input['act']) {
  51.             case 'Mail':
  52.                 $this->mail_member();
  53.                 break;
  54.             case 'AOL':
  55.                 $this->show_aim();
  56.                 break;
  57.             case 'ICQ':
  58.                 $this->show_icq();
  59.                 break;
  60.             case 'Invite':
  61.                 $this->invite_member();
  62.                 break;
  63.             default:
  64.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  65.                 break;
  66.         }
  67.         
  68.         $print->add_output("$this->output");
  69.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
  70.         
  71.     }
  72.      
  73.      
  74.     //****************************************************************/
  75.     // AOL CONSOLE:
  76.     //
  77.     //****************************************************************/
  78.         
  79.         
  80.     function show_aim() {
  81.         global $ibforums, $DB, $std, $print;
  82.         
  83.         require "./Skin/".$ibforums->skin_id."/skin_emails.php";
  84.  
  85.         $ibforums->lang    = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id );
  86.  
  87.         $this->html    = new skin_emails();
  88.         
  89.         //----------------------------------
  90.     
  91.         if (empty($ibforums->member['id']))
  92.         {
  93.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
  94.         }
  95.     
  96.         if ( empty($ibforums->input['MID']) )
  97.         {
  98.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  99.         }
  100.         
  101.         //----------------------------------
  102.         
  103.         if (! preg_match( "/^(\d+)$/" , $ibforums->input['MID'] ) )
  104.         {
  105.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  106.         }
  107.         
  108.         //----------------------------------
  109.         
  110.         $DB->query("SELECT name, id, aim_name from ibf_members WHERE id='".$ibforums->input['MID']."'");
  111.  
  112.         $member = $DB->fetch_row();
  113.         
  114.         //----------------------------------
  115.         
  116.         if (! $member['id'] )
  117.         {
  118.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
  119.         }
  120.         
  121.         //----------------------------------
  122.         
  123.         if (! $member['aim_name'] )
  124.         {
  125.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_aol' ) );
  126.         }
  127.         
  128.         $member['aim_name'] = str_replace(" ", "", $member['aim_name']);
  129.         
  130.         //----------------------------------
  131.         
  132.         $print->pop_up_window( "AOL CONSOLE", $this->html->aol_body( array( 'AOLNAME' => $member['aim_name'] ) ) );
  133.     
  134.     }
  135.     
  136.     //****************************************************************/
  137.     // ICQ CONSOLE:
  138.     //
  139.     //****************************************************************/
  140.     
  141.     
  142.     function show_icq() {
  143.         global $ibforums, $DB, $std, $print;
  144.         
  145.         require "./Skin/".$ibforums->skin_id."/skin_emails.php";
  146.  
  147.         $ibforums->lang    = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id);
  148.  
  149.         $this->html    = new skin_emails();
  150.         
  151.         //----------------------------------
  152.     
  153.         if (empty($ibforums->member['id'])) {
  154.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
  155.         }
  156.     
  157.         if ( empty($ibforums->input['MID']) )
  158.         {
  159.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  160.         }
  161.         
  162.         //----------------------------------
  163.         
  164.         if (! preg_match( "/^(\d+)$/" , $ibforums->input['MID'] ) )
  165.         {
  166.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  167.         }
  168.         
  169.         //----------------------------------
  170.         
  171.         $DB->query("SELECT name, id, icq_number from ibf_members WHERE id='".$ibforums->input['MID']."'");
  172.  
  173.         $member = $DB->fetch_row();
  174.         
  175.         //----------------------------------
  176.         
  177.         if (! $member['id'] )
  178.         {
  179.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
  180.         }
  181.         
  182.         //----------------------------------
  183.         
  184.         if (! $member['icq_number'] )
  185.         {
  186.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_icq' ) );
  187.         }
  188.         
  189.         //----------------------------------
  190.         
  191.         $html  = $this->html->pager_header( array( $ibforums->lang['icq_title'] ) );
  192.         
  193.         $html .= $this->html->icq_body( array( 'UIN' => $member['icq_number'] ) );
  194.         
  195.         $html .= $this->html->end_table();
  196.         
  197.         $print->pop_up_window( "ICQ CONSOLE", $html );
  198.     
  199.     
  200.     }
  201.     
  202.     //****************************************************************/
  203.     // MAIL MEMBER:
  204.     //
  205.     // Handles the routines called by clicking on the "email" button when
  206.     // reading topics
  207.     //****************************************************************/
  208.     
  209.     
  210.     function mail_member() {
  211.         global $ibforums, $DB, $std, $print;
  212.     
  213.         require "./sources/lib/emailer.php";
  214.         $this->email = new emailer();
  215.         
  216.         //----------------------------------
  217.         
  218.         require "./Skin/".$ibforums->skin_id."/skin_emails.php";
  219.  
  220.         $ibforums->lang    = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id );
  221.  
  222.         $this->html    = new skin_emails();
  223.         
  224.         //----------------------------------
  225.     
  226.         if (empty($ibforums->member['id']))
  227.         {
  228.             $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
  229.         }
  230.         
  231.         //----------------------------------
  232.         
  233.         if ($ibforums->input['CODE'] == '01')
  234.         {
  235.         
  236.             // Send the email, yippee
  237.             
  238.             if ( empty($ibforums->input['to']) )
  239.             {
  240.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  241.             }
  242.             
  243.             //----------------------------------
  244.             
  245.             if (! preg_match( "/^(\d+)$/" , $ibforums->input['to'] ) )
  246.             {
  247.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  248.             }
  249.             
  250.             //----------------------------------
  251.             
  252.             $DB->query("SELECT name, id, email, hide_email from ibf_members WHERE id='".$ibforums->input['to']."'");
  253.     
  254.             $member = $DB->fetch_row();
  255.             
  256.             //----------------------------------
  257.             
  258.             if (! $member['id'] )
  259.             {
  260.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
  261.             }
  262.             
  263.             /*if ($member['id'] == 1)
  264.             {
  265.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'private_email' ) );
  266.             }*/
  267.             
  268.             //----------------------------------
  269.             
  270.             $check_array = array ( 
  271.                                    'message'   =>  'no_message',
  272.                                    'subject'   =>  'no_subject'
  273.                                  );
  274.                              
  275.             foreach ($check_array as $input => $msg)
  276.             {
  277.                 if (empty($ibforums->input[$input]))
  278.                 {
  279.                     $std->Error( array( LEVEL => 1, MSG => $msg) );
  280.                 }
  281.             }
  282.             
  283.             $this->email->get_template("email_member");
  284.                 
  285.             $this->email->build_message( array(
  286.                                                 'MESSAGE'     => $ibforums->input['message'],
  287.                                                 'MEMBER_NAME' => $member['name'],
  288.                                                 'FROM_NAME'   => $ibforums->member['name']
  289.                                               )
  290.                                         );
  291.                                         
  292.             $this->email->subject = $ibforums->input['subject'];
  293.             $this->email->to      = $member['email'];
  294.             $this->email->from    = $ibforums->member['email'];
  295.             $this->email->send_mail();
  296.             
  297.             $forum_jump = $std->build_forum_jump();
  298.             $forum_jump = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $forum_jump);
  299.             
  300.             $this->output  = $this->html->sent_screen($member['name']);
  301.             
  302.             $this->output .= $this->html->forum_jump($forum_jump);
  303.             
  304.             $this->page_title = $ibforums->lang['email_sent'];
  305.             $this->nav        = array( $ibforums->lang['email_sent'] );
  306.             
  307.         }
  308.         else
  309.         {
  310.             // Show the form, booo...
  311.             
  312.             if ( empty($ibforums->input['MID']) )
  313.             {
  314.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  315.             }
  316.             
  317.             //----------------------------------
  318.             
  319.             if (! preg_match( "/^(\d+)$/" , $ibforums->input['MID'] ) )
  320.             {
  321.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
  322.             }
  323.             
  324.             //----------------------------------
  325.             
  326.             $DB->query("SELECT name, id, email, hide_email from ibf_members WHERE id='".$ibforums->input['MID']."'");
  327.     
  328.             $member = $DB->fetch_row();
  329.             
  330.             //----------------------------------
  331.             
  332.             if (! $member['id'] )
  333.             {
  334.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
  335.             }
  336.             
  337.             if ($member['hide_email'] == 1)
  338.             {
  339.                 $std->Error( array( 'LEVEL' => 1, 'MSG' => 'private_email' ) );
  340.             }
  341.             
  342.             //----------------------------------
  343.             
  344.             $this->output = $ibforums->vars['use_mail_form']
  345.                           ? $this->html->send_form(
  346.                                                       array(
  347.                                                               'NAME'   => $member['name'],
  348.                                                               'TO'     => $member['id'],
  349.                                                            )
  350.                                                      )
  351.                           : $this->html->show_address(
  352.                                                         array(
  353.                                                               'NAME'    => $member['name'],
  354.                                                               'ADDRESS' => $member['email'],
  355.                                                            )
  356.                                                      );
  357.                                                      
  358.             $this->page_title = $ibforums->lang['member_address_title'];
  359.             $this->nav        = array( $ibforums->lang['member_address_title'] );
  360.  
  361.         }
  362.         
  363.     }
  364.                 
  365.                 
  366.                 
  367.                 
  368. }
  369.  
  370. ?>
  371.  
  372.  
  373.  
  374.  
  375.  
  376.