authenticate_user_request(); $sloodle->load_module('blog', false); // No database data required // Attempt to validate the avatar $sloodle->validate_avatar(); $sloodle->user->login(); // Is blogging enabled? if (!$sloodle->module->is_enabled()) { $sloodle->response->quick_output(-10401, 'BLOG', 'Blogging is disabled on this site.', false); exit(); } // Check if the user has permission to create blog entries if (!$sloodle->module->user_can_write()) { $sloodle->response->quick_output(-10402, 'BLOG', 'User lacks permission to write blog entries.', false); exit(); } // Check for our additional parameters $sloodleblogsubject = $sloodle->request->optional_param('sloodleblogsubject', ''); $sloodleblogbody = $sloodle->request->optional_param('sloodleblogbody', ''); $sloodleblogvisibility = $sloodle->request->optional_param('sloodleblogvisibility', 'site'); // If subject or body parameters were given, then both are required if (!empty($sloodleblogsubject)) $sloodle->request->required_param('sloodleblogbody'); else if (!empty($sloodleblogbody)) $sloodle->request->required_param('sloodleblogsubject'); else { // Neither parameter was specified $sloodle->response->quick_output(1, 'OK', '', false); exit(); } // We need to know if all header data was retrieved $use_slurl = (isset($_SERVER['HTTP_X_SECONDLIFE_REGION']) && isset($_SERVER['HTTP_X_SECONDLIFE_LOCAL_POSITION'])); // Use the HTTP headers added by SL to get the region and position data, and construct a SLurl from them if ($use_slurl) { $region = $_SERVER['HTTP_X_SECONDLIFE_REGION']; $region = substr ( $region,0, strpos($region, '(' ) - 1 ); $position = $_SERVER['HTTP_X_SECONDLIFE_LOCAL_POSITION']; sloodle_debug('Constructing SLurl...
'); sscanf($position, "(%f, %f, %f)", $x, $y, $z); $slurl = "http://slurl.com/secondlife/" .$region ."/" .$x ."/" .$y ."/" .$z; $slurl = '' .$region .''; } else { $slurl = '['.get_string('unknown','sloodle').']'; } // Construct the final blog body $sloodleblogbody = get_string('postedfromsl','sloodle').': '.$slurl ."\n\n" .$sloodleblogbody; // Make all string data safe $sloodleblogsubject = addslashes(clean_text(stripslashes($sloodleblogsubject), FORMAT_PLAIN)); $sloodleblogbody = addslashes(clean_text(stripslashes($sloodleblogbody), FORMAT_MOODLE)); $sloodleblogvisibility = addslashes(clean_text(stripslashes($sloodleblogvisibility), FORMAT_PLAIN)); // Write the entry to the database if ($sloodle->module->add_entry($sloodleblogsubject, $sloodleblogbody, $sloodleblogvisibility)) { $sloodle->response->set_status_code(103); $sloodle->response->set_status_descriptor('OK'); } else { $sloodle->response->set_status_code(-1); $sloodle->response->set_status_descriptor('ERROR'); $sloodle->response->add_data_line('Failed to insert blog entry into database.'); } // Output the response $sloodle->response->render_to_output(); exit();