Stumped, any help?

Discussion in 'PHP' started by xxKillswitch, Sep 15, 2008.

  1. #1
    I am using Joomla 1.0.15 and the XAJAX plugin. If anyone has any development experience with the both, please help me! I am making a custom forum component for Joomla and using XAJAX to process my forms. The problem is that the message and title is not entered into the database, but the date, username, and forum id is entered right.

    Here is the function XAJAX uses to process all things. It's a bit sloppy at the moment due to the number of times I've had to rewrite/insert new stuff into it.

    
    function newTopicData( $aFormData ) {
    
        global $database;
    
        // Check magic quotes setting
        if( !get_magic_quotes_gpc() ) {
            $aFormData = array_map( 'addslashes', $aFormData );
        }
    
        // Instantiate object response
        $objResponse = new xajaxResponse();
    
        $userid = base64_decode( $aFormData['identifier'] );
    
        // Check some data for validity
        // Match username against encoded userid, could probably be spoofed
        // So match against users session in database as well
        $database->setQuery( "SELECT id, username FROM #__users WHERE id = '".$userid."'" );
        $userCheck = null;
        if( !$database->loadObject( $userCheck ) ) {
            $message = 'Stop tampering with our forms...';
        } else {
            if( $userCheck->username !== $aFormData['username'] ) {
                $message = 'Stop tampering with our forms...';
            } else {
                $database->setQuery( "SELECT session_id FROM #__session WHERE userid = '".$userid."'" );
                $database->loadObject( $sescheck );
                if( $aFormData['token'] !== $sescheck->session_id ) {
                    $message = 'We believe you are trying to tamper with our forms... Go away...';
                } else {
                    // Check hidden field for spammers
                    if( $aFormData['check'] !== '' ) {
                        $message = 'You didn\'t properly fill out the form.  Please try again.';
                    } else {
                        if( ( $aFormData['message'] = null ) ) {
                            $message = 'Ancient Majiks say you must enter a message';
                        } else if( ( $aFormData['title'] = null ) ) {
                            $message = 'Ancient Majiks say you must enter a title?';
                        } else {
    
                            $date = getdate();
                            $insert = new stdClass();
                            $insert->id       = null;
                            $insert->title    = mysql_real_escape_string( $aFormData['title'] );
                            $insert->content  = mysql_real_escape_string( $aFormData['message'] );
                            $insert->poster   = mysql_real_escape_string( $aFormData['username'] );
                            $insert->forum_id = mysql_real_escape_string( (int)$aFormData['forum_id'] );
                            $insert->date     = $date;
    
                            if( !$database->insertObject( '#__jbb_topics', $insert, 'id' ) ) {
                                $message = $database->stderr();
                            } else {
                              // Get id of new topic
                              $database->setQuery( "SELECT id FROM #__jbb_topics WHERE poster = '".$insert->poster."' ORDER BY id LIMIT 1" );
                              $idobject = null;
                              $database->loadObject( $idobject );
    
                              $message = '<p>Your topic, ' .$insert->title. ' has successfully been added.  You will now be redirected to your topic.  If you are not automatically redirected, please <a href="#">follow this link</a>.</p>';
                              $objResponse->addRedirect( sefReltoAbs( 'index.php?option=com_joomlabb&task=view_topic&topic_id='.$idobject->id ) );
                            }
                        }
                    }
                }
            }
       }
       // Get XAJAX object response
       sleep(3);  /** Sleep for three seconds for loading effect */
       $objResponse->addAssign( 'reqbox', 'innerHTML', $message );
       return $objResponse->getXML();
    }
    
    Code (markup):
    Basically, it checks a few things against the user session and so forth and after it clears, starts to process the data into the database. As I said, the title and all else is entered except for the message content and the title. The title was entered right earlier before I removed a cleaning function, but it really wasn't needed (will clean it via the frontend). I've made sure the editor id/name was correct and just can not figure this out.

    Any help?
     
    xxKillswitch, Sep 15, 2008 IP