Location: PHPKode > projects > PBBoard > PBBoard_v2.1.4/Upload/modules/misc.module.php
<?php
session_start();

$CALL_SYSTEM				=	array();
$CALL_SYSTEM['SECTION'] 	= 	true;
$CALL_SYSTEM['REPUTATION'] 	= 	true;
$CALL_SYSTEM['RATING']   	= 	true;
$CALL_SYSTEM['SUBJECT'] 	= 	true;
$CALL_SYSTEM['REPLY'] 		= 	true;
$CALL_SYSTEM['EMAILED'] 		= 	true;

(!defined('IN_PowerBB')) ? die() : '';

include('common.php');
define('JAVASCRIPT_PowerCode',true);

define('CLASS_NAME','PowerBBMiscMOD');

class PowerBBMiscMOD
{
	function run()
	{
		global $PowerBB;

   		/** Show Rules form **/
		if ($PowerBB->_GET['rules'])
		{

		$this->_GetRules();

		}
		// Go to the page
		if ($PowerBB->_GET['pagenav'])
		{
			$this->_GoPagenav();
		}

		if ($PowerBB->_GET['pagenav_forum'])
		{
			$this->_GoPagenav_forum();
		}
       if ($PowerBB->_GET['pagenav_memberlist'])
       {
          $this->_GoPagenav_memberlist();
       }
       if ($PowerBB->_GET['pagenav_pm'])
       {
          $this->_GoPagenav_pm();
       }
       if ($PowerBB->_GET['pagenav_search'])
       {
          $this->_GoPagenav_search();
       }
		// rating subject
		if ($PowerBB->_GET['rating'])
		{
			$this->_RatingSubject();
		}

		// Who posted
		if ($PowerBB->_GET['whoposted'])
		{
			$this->_Whoposted();
		}
		// members reputation
		if ($PowerBB->_GET['subject_reputation'])
		{
			$this->_SubjectSendReputation();
		}
		elseif ($PowerBB->_GET['reply_reputation'])
		{
			$this->_ReplySendReputation();
		}
		// send subject to friend
		if ($PowerBB->_GET['sendtofriend'])
		{
			$this->_GoToPageSendToFriend();
		}
		elseif ($PowerBB->_GET['startsendtofriend'])
		{
			$this->_StartSendToFriend();
		}
		// add subscription
		if ($PowerBB->_GET['addsubscription'])
		{
			$this->_StartAddSubscription();
		}
		if ($PowerBB->_GET['frame_form'])
		{
			$this->_StartAddFrame();
		}
		if ($PowerBB->_GET['gradient_form'])
		{
			$this->_StartAddGradient();
		}
		if ($PowerBB->_GET['poem_form'])
		{
			$this->_StartAddPoem();
		}
		if ($PowerBB->_GET['poem_template'])
		{
			$this->_StartAddPoemTemplat();
		}

	}


	/**
	 * Print Rules
	 */
	function _GetRules()
	{
		global $PowerBB;
         $PowerBB->functions->ShowHeader();

         $PowerBB->Powerparse->replace_smiles($PowerBB->_CONF['info_row']['rules']);
         $PowerBB->_CONF['info_row']['rules'] = $PowerBB->Powerparse->replace($PowerBB->_CONF['info_row']['rules']);
         $PowerBB->template->assign('rules',$PowerBB->_CONF['info_row']['rules']);

		$PowerBB->template->display('rules_board_main');
		$PowerBB->functions->GetFooter();

	}

	function _GoPagenav()
	{
		global $PowerBB;
        $PowerBB->_POST['count'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'intval');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'html');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'sql');
		if (empty($PowerBB->_POST['count']))
		{
         $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_write_the_page_number']);
		}
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'intval');
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'html');
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'sql');

		$PowerBB->functions->ShowHeader();

		$count = ($PowerBB->_CONF['info_row']['perpage'] * $PowerBB->_POST['count'] - $PowerBB->_CONF['info_row']['perpage']);

       $PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['go_page']  . ' ('. $PowerBB->_POST['count'] .') '. $PowerBB->_CONF['template']['lang']['Please_wait']);
	 $PowerBB->functions->redirect('index.php?page=topic&amp;show=1&amp;id=' . $PowerBB->_POST['subject_id'] . '&amp;count=' . $count);
     $PowerBB->functions->GetFooter();

	}

	function _GoPagenav_forum()
	{
		global $PowerBB;
        $PowerBB->_POST['count'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'intval');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'html');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'sql');
  		if (empty($PowerBB->_POST['count']))
		{
         $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_write_the_page_number']);
		}
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'intval');
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'html');
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'sql');

		$PowerBB->functions->ShowHeader();

		$count = ($PowerBB->_CONF['info_row']['subject_perpage'] * $PowerBB->_POST['count'] - $PowerBB->_CONF['info_row']['subject_perpage']);

       $PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['go_page'] . ' ('. $PowerBB->_POST['count'] .') '. $PowerBB->_CONF['template']['lang']['Please_wait']);
	 $PowerBB->functions->redirect('index.php?page=forum&amp;show=1&amp;id=' . $PowerBB->_POST['section_id'] . '&amp;count=' . $count);
     $PowerBB->functions->GetFooter();

	}
    function _GoPagenav_pm()
    {
       global $PowerBB;
        $PowerBB->_POST['count'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'intval');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'html');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'sql');

       if (empty($PowerBB->_POST['count']))
       {
        $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_write_the_page_number']);
       }
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'intval');
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'html');
               $PowerBB->_POST['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['subject_id'],'sql');

       $PowerBB->functions->ShowHeader();

       $count = ($PowerBB->_CONF['info_row']['perpage'] * $PowerBB->_POST['count'] - $PowerBB->_CONF['info_row']['perpage']);

      $PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['go_page'] . ' ('. $PowerBB->_POST['count'] .') '. $PowerBB->_CONF['template']['lang']['Please_wait']);
    $PowerBB->functions->redirect('index.php?page=pm_list&list=1&folder='.$PowerBB->_POST['folder'].'&count=' . $count);
    $PowerBB->functions->GetFooter();

    }

   function _GoPagenav_search()
    {
       global $PowerBB;

       if (empty($PowerBB->_POST['count']))
       {
        $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_write_the_page_number']);
       }
        $PowerBB->_POST['count'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'intval');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'html');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'sql');

       $PowerBB->functions->ShowHeader();

       $count = ($PowerBB->_CONF['info_row']['perpage'] * $PowerBB->_POST['count'] - $PowerBB->_CONF['info_row']['perpage']);

      $PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['go_page'] . ' ('. $PowerBB->_POST['count'] .') '. $PowerBB->_CONF['template']['lang']['Please_wait']);
    $PowerBB->functions->redirect($PowerBB->_POST['location'].'&count=' . $count);
    $PowerBB->functions->GetFooter();

    }

  function _GoPagenav_memberlist()
    {
       global $PowerBB;

       if (empty($PowerBB->_POST['count']))
       {
        $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_write_the_page_number']);
       }
        $PowerBB->_POST['count'] = $PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'intval');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'html');
  		$PowerBB->_POST['count'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['count'],'sql');

       $PowerBB->functions->ShowHeader();

       $count = ($PowerBB->_CONF['info_row']['perpage'] * $PowerBB->_POST['count'] - $PowerBB->_CONF['info_row']['perpage']);

      $PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['go_page'] . ' ('. $PowerBB->_POST['count'] .') '. $PowerBB->_CONF['template']['lang']['Please_wait']);
    $PowerBB->functions->redirect('index.php?page=member_list&index=1&show=1&count=' . $count);
    $PowerBB->functions->GetFooter();

    }

	function _SubjectSendReputation()
	{
		global $PowerBB;

		if (!$PowerBB->_CONF['member_permission'])
		{
		 $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['no_vistor_Reputation']);
		}

    	 if ($PowerBB->_POST['username'] == $PowerBB->_POST['reputationusername'])
		 {
           $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['you_cant_Reputation_self']);
         }

  		$PowerBB->_POST['reputationusername'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationusername'],'html');
  		$PowerBB->_POST['reputationusername'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationusername'],'sql');
  		$PowerBB->_POST['reputationcomment'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationcomment'],'html');
  		$PowerBB->_POST['reputationcomment'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationcomment'],'sql');
  		$PowerBB->_POST['username'] 	        = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['username'],'sql');
  		$PowerBB->_POST['subject_title'] 	    = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['subject_title'],'html');
  		$PowerBB->_POST['subject_title'] 	    = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['subject_title'],'sql');

         /** Get the Reputation information **/
		$RepArr 			= 	array();
		$RepArr['where'] 	= 	array('subject_id',$PowerBB->_POST['subject_id']);

		$this->ReputationInfo = $PowerBB->reputation->GetReputationInfo($RepArr);

        if ($this->ReputationInfo['by_username'] == $PowerBB->_POST['reputationusername'])
        {
        $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['you_cant_Reputation_towez']);
        }

	  $reputation = $PowerBB->_POST['username'];
	  $reputation_number = $PowerBB->_CONF['group_info']['reputation_number'];
	  $update = $PowerBB->DB->sql_query("UPDATE " . $PowerBB->table['member'] . " SET reputation = reputation + '$reputation_number' WHERE username ='$reputation'");

	  	if ($update)
		{
		    $time=time();

        	$ReputationArr 			= 	array();
			$ReputationArr['field']	=	array();

			$ReputationArr['field']['by_username'] 	        = 	$PowerBB->_POST['reputationusername'];
			$ReputationArr['field']['username'] 	        = 	$PowerBB->_POST['username'];
			$ReputationArr['field']['subject_title'] 	    = 	$PowerBB->_POST['subject_title'];
			$ReputationArr['field']['subject_id'] 	        = 	$PowerBB->_POST['subject_id'];
			$ReputationArr['field']['comments'] 	        = 	$PowerBB->_POST['reputationcomment'];
			$ReputationArr['field']['reputationdate'] 	    = 	$PowerBB->_CONF['now'];
			$ReputationArr['field']['reputationread'] 	    = 	'1';
			$ReputationArr['get_id']					    =	true;

			$insert = $PowerBB->reputation->InsertReputation($ReputationArr);
	        if ($insert)
	        {
	          $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['Reputation_successfully']);
	        }
		}


	}

	function _ReplySendReputation()
	{
		global $PowerBB;

        if (!$PowerBB->_CONF['member_permission'])
		{
		$PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['no_vistor_Reputation']);
		}
    	 if ($PowerBB->_POST['username'] == $PowerBB->_POST['reputationusername'])
		 {
           $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['you_cant_Reputation_self']);
         }

  		$PowerBB->_POST['reputationusername'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationusername'],'html');
  		$PowerBB->_POST['reputationusername'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationusername'],'sql');
  		$PowerBB->_POST['reputationcomment'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationcomment'],'html');
  		$PowerBB->_POST['reputationcomment'] 	= 	$PowerBB->functions->CleanVariable($PowerBB->_POST['reputationcomment'],'sql');
  		$PowerBB->_POST['username'] 	        = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['username'],'sql');
  		$PowerBB->_POST['subject_title'] 	    = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['subject_title'],'html');
  		$PowerBB->_POST['subject_title'] 	    = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['subject_title'],'sql');

         /** Get the Reputation information **/
		$RepArr 			= 	array();
		$RepArr['where'] 	= 	array('reply_id',$PowerBB->_POST['reply_id']);

		$this->ReputationInfo = $PowerBB->reputation->GetReputationInfo($RepArr);

         if ($this->ReputationInfo['by_username'] == $PowerBB->_POST['reputationusername'])
		 {
          $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['you_cant_Reputation_towez_to_Reply']);
         }

	  $reputation = $PowerBB->_POST['username'];
	  $reputation_number = $PowerBB->_CONF['group_info']['reputation_number'];
	  $update = $PowerBB->DB->sql_query("UPDATE " . $PowerBB->table['member'] . " SET reputation = reputation + '$reputation_number' WHERE username ='$reputation'");

	  	if ($update)
		{


        	$ReputationArr 			= 	array();
			$ReputationArr['field']	=	array();

			$ReputationArr['field']['by_username'] 	        = 	$PowerBB->_POST['reputationusername'];
			$ReputationArr['field']['username'] 	        = 	$PowerBB->_POST['username'];
			$ReputationArr['field']['subject_title'] 	    = 	$PowerBB->_POST['subject_title'];
			$ReputationArr['field']['reply_id'] 	        = 	$PowerBB->_POST['reply_id'];
			$ReputationArr['field']['subject_id'] 	        = 	$PowerBB->_POST['subject_id'];
			$ReputationArr['field']['comments'] 	        = 	$PowerBB->_POST['reputationcomment'];
			$ReputationArr['field']['reputationdate'] 	    = 	$PowerBB->_CONF['now'];
			$ReputationArr['field']['peg_count'] 	        = 	$PowerBB->_GET['count'];
            $ReputationArr['field']['reputationread'] 	    = 	'1';
			$ReputationArr['get_id']					    =	true;

			$insert = $PowerBB->reputation->InsertReputation($ReputationArr);

		 if ($insert)
		 {
           $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['Reputation_successfully']);
         }

		}

	}

	/**
	 * rating subject
	 */
	function _RatingSubject()
	{
		global $PowerBB;

		if (!$PowerBB->_CONF['member_permission'])
		{
		 $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['no_vistor_Reputation']);
		}
        $PowerBB->_GET['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_GET['subject_id'],'intval');


		// If time out For Editing Disable View Icon Edite
		$SubjectArr = array();
		$SubjectArr['where'] = array('id',$PowerBB->_POST['subject_id']);

		$SubjectInfo = $PowerBB->subject->GetSubjectInfo($SubjectArr);

    	 if ($PowerBB->_POST['by_username'] == $SubjectInfo['writer'])
		 {
           $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['you_cant_Rating_self']);
         }

         /** Get the Rating information **/
		$RepArr 			= 	array();
		$RepArr['where'] 	= 	array('subject_id',$PowerBB->_POST['subject_id']);

		$this->RatingInfo = $PowerBB->rating->GetRatingInfo($RepArr);

         if ($this->RatingInfo['by_username'] == $PowerBB->_POST['by_username'])
		 {
            $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['you_cant_Rating_towez']);
         }

	  $rating = $PowerBB->_POST['subject_id'];
	  $rating_number = $PowerBB->_POST['vote'];
	  $update = $PowerBB->DB->sql_query("UPDATE " . $PowerBB->table['subject'] . " SET rating = rating + '$rating_number' WHERE id ='$rating'");

	  	if ($update)
		{
  		$PowerBB->_POST['subject_title']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['gender'],'sql');
		$PowerBB->_POST['username']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['username'],'sql');
		$PowerBB->_POST['by_username']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['by_username'],'sql');

        	$RatingArr 			= 	array();
			$RatingArr['field']	=	array();

			$RatingArr['field']['username'] 	        = 	$PowerBB->_POST['username'];
			$RatingArr['field']['by_username'] 	        = 	$PowerBB->_POST['by_username'];
			$RatingArr['field']['subject_title'] 	    = 	$PowerBB->_POST['subject_title'];
			$RatingArr['field']['subject_id'] 	        = 	$PowerBB->_POST['subject_id'];
			$RatingArr['field']['ratingdate'] 	        = 	$PowerBB->_CONF['now'];
			$RatingArr['get_id']					    =	true;

			$insert = $PowerBB->rating->InsertRating($RatingArr);
		 if ($insert)
		 {
           $PowerBB->functions->reputation_alert($PowerBB->_CONF['template']['lang']['Rating_successfully']);
         }
		}
	}


 	/**
	 * Who posted
	 */
	function _Whoposted()
	{
		global $PowerBB;


		 // Who posted
        $PowerBB->_GET['subject_id'] = $PowerBB->functions->CleanVariable($PowerBB->_GET['subject_id'],'intval');
        $Posted_number = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " WHERE subject_id='" . $PowerBB->_GET['subject_id'] . "' and delete_topic <>1"));
        $PowerBB->template->assign('Posted_number',$Posted_number);

         $PowerBB->template->display('who_posted1');

		 $subject_id = $PowerBB->_GET['subject_id'];
		 $ReplyArr = $PowerBB->DB->sql_query("SELECT Distinct writer FROM " . $PowerBB->table['reply'] . " WHERE subject_id = '$subject_id'");

		 	while($r = $PowerBB->DB->sql_fetch_array($ReplyArr))
 			{

 				$PowerBB->template->assign('WhoPosted',$r);

 				  $Posted_writer_number = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " WHERE subject_id='" . $PowerBB->_GET['subject_id'] . "' and writer='" . $r['writer'] . "' and delete_topic <>1"));
                  $PowerBB->template->assign('Posted_writer_number',$Posted_writer_number);
                  $PowerBB->template->assign('subject_id',$subject_id);
                  $PowerBB->template->assign('reply_id',$r['id']);

 				$PowerBB->template->display('who_posted2');

 			}

 			$PowerBB->template->display('who_posted3');
	}

	/**
	 * send subject to friend
	 */
	function _GoToPageSendToFriend()
	{
		global $PowerBB;
         $PowerBB->functions->ShowHeader();
      	$PowerBB->_GET['id'] = $PowerBB->functions->CleanVariable($PowerBB->_GET['id'],'intval');
		if (empty($PowerBB->_GET['id']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['path_not_true']);
		}
		$SubjectArr = array();
		$SubjectArr['where'] = array('id',$PowerBB->_GET['id']);

		$this->Subject = $PowerBB->subject->GetSubjectInfo($SubjectArr);

		$PowerBB->template->assign('SubjectInfo',$this->Subject);
		if ($PowerBB->_CONF['member_permission'])
		{
		$PowerBB->template->assign('Sender',$PowerBB->_CONF['member_row']['username']);
		}
		else
		{
		$PowerBB->template->assign('Sender',$PowerBB->_CONF['template']['lang']['Guest']);
		}
		$PowerBB->template->assign('Adress',$Adress = $PowerBB->functions->GetForumAdress());
		$PowerBB->template->display('send_subject_to_friend');
		$PowerBB->functions->GetFooter();

	}

	function _StartSendToFriend()
	{
		global $PowerBB;

		$PowerBB->functions->ShowHeader();
  		$PowerBB->_POST['text']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['text'],'sql');
		$PowerBB->_POST['username']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['username'],'sql');
		$PowerBB->_POST['sendername']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['sendername'],'sql');
        $PowerBB->_POST['title']   = 	$PowerBB->functions->CleanVariable($PowerBB->_POST['title'],'sql');


     	//////////

		if (empty($PowerBB->_POST['text']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['You_do_not_type_the_letter']);
		}
		if (!$PowerBB->_CONF['member_permission'])
		{
			if (empty($PowerBB->_POST['username']))
			{
				$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['You_do_not_type_your_name']);
			}
		}

		if (empty($PowerBB->_POST['sendername']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['noSendername']);
		}
		if (empty($PowerBB->_POST['Sendermail']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['noSendermail']);
		}
		if (empty($PowerBB->_POST['title']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['notitlesendsubjecttofriend']);
		}
		// Check if the email is valid, This line will prevent any false email
		if (!$PowerBB->functions->CheckEmail($PowerBB->_POST['Sendermail']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_enter_a_valid_e-mail']);
		}

         if(md5($PowerBB->_POST['code']) != $_SESSION['key'] and !$PowerBB->_CONF['member_permission'])
		 {
          $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Code_that_you_enter_the_wrong']);
	     }


            $PowerBB->_POST['text'] = $PowerBB->Powerparse->replace($PowerBB->_POST['text']);
          	$PowerBB->_POST['text'] = str_ireplace('{39}',"'",$PowerBB->_POST['text']);
	        $PowerBB->_POST['text'] = str_ireplace('cookie','**',$PowerBB->_POST['text']);
	        $censorwords = preg_split('#[ \r\n\t]+#', $PowerBB->_CONF['info_row']['censorwords'], -1, PREG_SPLIT_NO_EMPTY);
	        $PowerBB->_POST['text'] = str_ireplace($censorwords,'**', $PowerBB->_POST['text']);

		if ($PowerBB->_CONF['member_permission'])
		{
		$username = $PowerBB->_CONF['member_row']['username'];
		}
		else
		{
		$username = $PowerBB->_POST['username'];
		}

		if ($PowerBB->_CONF['member_permission'])
		{
		$email = $PowerBB->_CONF['member_row']['email'];
		}
		else
		{
		$email = $PowerBB->_CONF['info_row']['title'];
		}

       $Adress_end	= 	'<a href="'.$PowerBB->functions->GetForumAdress().'index.php'.'">'.$PowerBB->_CONF['info_row']['title'].'</a>';

		$Form_name = '<br />'.$PowerBB->_CONF['template']['lang']['welc_Sender'].''.$PowerBB->_POST['sendername'].' '.$PowerBB->_CONF['template']['lang']['thes_maseege_from_subjecttofriend'].$username.'<br />';
		$Form_Massege ='<br>
	---------------------------------------------------<br>
	'.$PowerBB->_CONF['template']['lang']['Warning_send2'].'<br>
	---------------------------------------------------<br>
'.$PowerBB->_CONF['template']['lang']['Team'].' ' . $Adress_end .'.<br>
	&nbsp;</p>';

			if ($PowerBB->_CONF['info_row']['mailer']=='phpmail')
			{
	         $send = $PowerBB->functions->mail($PowerBB->_POST['Sendermail'],$PowerBB->_POST['title'],$Form_name.$PowerBB->_POST['text'].$Form_Massege,$email);
			}
			elseif ($PowerBB->_CONF['info_row']['mailer']=='smtp')
			{
			$to = $PowerBB->_POST['Sendermail'];
			$fromname = $PowerBB->_CONF['info_row']['title'];
			$message = $Form_name.$PowerBB->_POST['text'].$Form_Massege;
			$subject = $PowerBB->_POST['title'];
			$from = $email;
            $Send = $PowerBB->functions->send_this_smtp($to,$fromname,$message,$subject,$from);
			}
	$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['your_message_has_been_sent_successfully']);
	$PowerBB->functions->redirect('index.php?page=topic&amp;show=1&amp;id='.$PowerBB->_POST['subject_id']);
	$PowerBB->functions->GetFooter();

	}

	function _StartAddSubscription()
	{
		global $PowerBB;

		$PowerBB->functions->ShowHeader();

      	$PowerBB->_GET['id'] = $PowerBB->functions->CleanVariable($PowerBB->_GET['id'],'intval');
		if (empty($PowerBB->_GET['id']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['path_not_true']);
		}


		if ($PowerBB->_CONF['info_row']['allowed_emailed'] == '1')
		{

		$SubjectArr = array();
		$SubjectArr['where'] = array('id',$PowerBB->_GET['id']);

		$this->Subject = $PowerBB->subject->GetSubjectInfo($SubjectArr);

		$SectionInfoid = $this->Subject['section'];
		$SubjectInfoid = $PowerBB->_GET['id'];
		$member_row_id = $PowerBB->_CONF['member_row']['id'];

		$subject_user_emailed_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['emailed'] . " WHERE subject_id='$SubjectInfoid' and user_id ='$member_row_id'"));



		$EmailedArr 			= 	array();
		$EmailedArr['where'] 	= 	array('subject_id',$PowerBB->_GET['id']);

		$this->EmailedInfo = $PowerBB->emailed->GetEmailedInfo($EmailedArr);


			if ($subject_user_emailed_nm < 1)
			{
			$EmailedArr 								= 	array();
			$EmailedArr['get_id']						=	true;
			$EmailedArr['field']						=	array();
			$EmailedArr['field']['user_id'] 			= 	$PowerBB->_CONF['member_row']['id'];
			$EmailedArr['field']['subject_id'] 			= 	$PowerBB->_GET['id'];
			$EmailedArr['field']['subject_title'] 		= 	$this->Subject['title'];

			$Insert = $PowerBB->emailed->InsertEmailed($EmailedArr);
			}

		///////////
	$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['addsubscription_successfully']);
	$PowerBB->functions->redirect('index.php?page=topic&amp;show=1&amp;id='.$PowerBB->_GET['id']);
      $PowerBB->functions->GetFooter();
		}

    }

 	/**
	 * Open frame peg
	 */
	function _StartAddFrame()
	{
		global $PowerBB;
	$PowerBB->template->display('frame_form');
	}
 	/**
	 * Open Gradient peg
	 */
	function _StartAddGradient()
	{
		global $PowerBB;
	$PowerBB->template->display('gradient_form');
	}

 	/**
	 * Open Poem peg
	 */
	function _StartAddPoem()
	{
		global $PowerBB;
	$PowerBB->template->display('poem_form');
	}
 	/**
	 * Open PoemTemplat peg
	 */
	function _StartAddPoemTemplat()
	{
		global $PowerBB;
	$PowerBB->template->display('poem_template');
	}



}

?>
Return current item: PBBoard