Mutuo Rich Source Code - PHP

PHP Class

Using PHP:

/**
* Class Mutuo Rich version 1
* @abstract Mutuo Rich is a class that deals with link exchange requests. It still have scope for improvement.
* @example http://seo.bubaweb.com/mutuo_rich_link_exchange_form.html
* @author Thales Jacobi @link http://www.thalesjacobi.com
* @version 1.0
* @todo Validations, reciprocal links verification
* Hosted by: Bubaweb.com @link http://seo.bubaweb.com/
* Created at 08/OCT/09
*/
class exchangeLinks
    {
    var $params='';
    var $error_check=false;
    
    /**
    * Contruct
    * 
    * @param mixed $params
    * @return string
    */
    function exchangeLinks($params='')
        {
        if(!$params)return $this->output_class_error();
        $this->params=$params;
        }
    
    /**
    * Standard class error message output
    * 
    */
    function output_class_error()
        {
        $dom = new DomDocument('1.0'); 
        $link_exchange_result = $dom->appendChild($dom->createElement('link_exchange_result')); 
        $system_message = $link_exchange_result->appendChild($dom->createElement('message'));
        $system_message->appendChild($dom->createTextNode("No parameters indentified. Refer to <a href='http://seo.bubaweb.com/exchange_links_engine.html'>http://seo.bubaweb.com/exchange_links_engine.html</a> for more information.")); 
        $dom->formatOutput = true;
        return $dom->saveXML();
        }

    /**
    * Send request to given email
    * 
    */
    function sent_exchange_request()
        {
        $dom = new DomDocument('1.0'); 
        $link_exchange_result = $dom->appendChild($dom->createElement('link_exchange_result')); 
        # clean up
        $this->params['link_to_use']=stripslashes($this->params['link_to_use']);
        $this->params['link_to_use']=stripslashes($this->params['link_to_use']);
        $this->params['link_to_use']=stripslashes($this->params['link_to_use']);
        $this->params['link_to_use']=stripslashes($this->params['link_to_use']);
        
        # Load XML
        $name="Mutuo Rich - link exchange";
        $from=stripslashes("seo.linkexchange@bubaweb.com");
        $subject=stripslashes("Exchange links request");

        $msg  = "** This is a link exchange request \r\n\n";  //add sender's name to the message
        $msg  = "From\r\n\t\t ".stripslashes(ucfirst($this->params['full_name']))." \r\n";  //add sender's name to the message
        $msg .= "Email\r\n\t\t ".stripslashes(strtolower($this->params['email']))." \r\n";  //add sender's email to the message
        $msg .= "Placed your link on this address\r\n\t\t ".stripslashes(strtolower($this->params['reciprocal_url']))." \r\n";  //add sender's email to the message
        $msg .= "And asks you to place this link into your website\r\n\t\t ".stripslashes(strtolower($this->params['link_to_use']))." \r\n";  //add sender's email to the message
        $msg .= "\r\n\n ------------------------------------------------------------------------------------------------------------------------------------- \r\n\n";  //the message itself
        $msg .= "Thanks for using Mutuo Rich\r\nhttp://seo.bubaweb.com\r\nA Bubaweb.com group application. \r\n\n\n";  //the message itself
        $msg .= "* Thales Jacobi\r\nthales.jacobi@bubaweb.com\r\n";  //the message itself
        $msg .= "Technical responsible \r\n";  //the message itself
        $msg .= "\r\n\n ------------------------------------------------------------------------------------------------------------------------------------- \r\n\n";  //the message itself
        #echo "<pre>".print_r($this->params,true)."</pre>";
        if (mail(stripslashes($this->params['to_email']), $subject, $msg, "From: $name <$from>\r\nReply-To: ".stripslashes($this->params['email'])."\r\nReturn-Path: $from\r\n")) 
            {
            //Message sent!
            //It the message that will be displayed when the user click the sumbit button
            //You can modify the text if you want
            $xml_message = $link_exchange_result->appendChild($dom->createElement('message'));
            $xml_message->appendChild($dom->createTextNode("Message sent! Please wait for contact and/or confirmation of your link exchange request.")); 
            }
        else 
            {
            $system_message = $link_exchange_result->appendChild($dom->createElement('message'));
            $system_message->appendChild($dom->createTextNode("System failed."));
            }
        $dom->formatOutput = true;
        return $dom->saveXML();
        }
    }