Location: PHPKode > projects > MJGUEST > mjguest/request.xml.php
<?php

	/*
	+---------------------------------------------------------------
	|
	|	MJGUEST
	|	============================================================
	|	Copyright (c) 2002-2008 Giacomo "mdsjack" Menni
	|	Terms of agreement and support at www.mdsjack.bo.it
	|
	+---------------------------------------------------------------
	|	[ CORE MODULE ]
	|	HTTP Request responder
	+---------------------------------------------------------------
	*/
	
	ob_start();
	
	header('Content-Type: text/xml; charset=UTF-8');
	
	echo
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response>';
	
	define('mjguest_basedir', false);
	
	require ('mjguest.core.php');
	
	$mjguest = new guestbook(false);
	$mjguest->loadmodule('user');
	
	$_REQUEST = remove_magic_quotes_gpc($_REQUEST);
	
	switch ($_REQUEST['do'])
	{
		case 'get_logincode':
			
			$mjguest->user->set('logincode', uniqid(rand(), true));
			
			echo '<![CDATA[',$mjguest->user->get('logincode'),']]>';
			
		break;
		
		case 'host':
			
			echo '<![CDATA[',$mjguest->user->get_host($_REQUEST['ip']),']]>';
			
		break;
		
		case 'delentry':
			
			$mjguest->db_start();
			
			if ($mjguest->user->get('status') <= 1) echo '0';
			else
			{
				$mjguest->db->ask('row_delete', null, array('[TBL=entries]', 'id', (int) $_REQUEST['id']));
				$mjguest->db->ask('optimize', null, '[TBL=entries]');
				
				echo '1';
			}
			
		break;
		
		case 'getcountry':
			
			echo '<![CDATA[',( $mjguest->user->get('status') > 1 ? '' : $mjguest->user->get('country') ),']]>';
			
		break;
		
		case 'check_captcha':
			
			echo (int) (md5((int)$_REQUEST['captcha']) == $mjguest->user->get('captcha'));
			
		break;
		
		case 'approve':
			
			if ($mjguest->user->get('status') <= 1) echo '0';
			else
			{
				$mjguest->db_start();
				$mjguest->db->ask('approve', null, (int) $_REQUEST['id']);
				
				echo '1';
			}
			
		break;
		
		case 'reply':
			
			if ($mjguest->user->get('status') > 1)
			{
				$mjguest->db_start();
				
				$mjguest->loadmodule('processor_in');
				
				$_POST['reply'] = $mjguest->processor_in->compile_reply($_POST['reply']);
				
				$mjguest->db->ask('reply_save', null, array($mjguest->db->escape($_POST['reply']), $_POST['id']));
				
				if ($mjguest->db->error) exit;
				
				$mjguest->loadmodule('settings');
				$mjguest->loadmodule('gui');
				$mjguest->loadmodule('processor_out');
				
				$mjguest->processor_out->xhtml_text($_POST['reply']);
				$mjguest->processor_out->compile_urls($_POST['reply']);
				$_POST['reply'] = preg_replace($mjguest->processor_out->pattern['name'], '"<b>".(!empty($mjguest->settings->param["name_$1"]) ? $mjguest->settings->param["name_$1"] : $mjguest->gui->say["$1"])."</b>: "', $_POST['reply']);
				
				echo '<![CDATA[',$_POST['reply'],']]>';
			}
			
		break;
		
		case 'entries_load':
			
			$mjguest->db_start();
			
			$mjguest->loadmodule('settings');
			$mjguest->loadmodule('entry');
			$mjguest->loadmodule('gui');
			
			if (!$mjguest->entry->get_set()) break;
			
			while ($mjguest->entry->get_each())
				echo
'<entry id="',$mjguest->entry->detail['RAW']['id'],'">
	<name>',$mjguest->entry->detail['name'],'</name>
	<avatar><![CDATA[',$mjguest->entry->detail['avatar'],']]></avatar>
	<date timestamp="',$mjguest->entry->detail['RAW']['datetime'],'">',$mjguest->entry->detail['datetime'],'</date>
	<country><![CDATA[',$mjguest->entry->detail['country'],']]></country>
	<icons><![CDATA[',$mjguest->entry->detail['id'],$mjguest->entry->detail['ip'],$mjguest->entry->detail['email'],$mjguest->entry->detail['web'],$mjguest->entry->detail['chat'],']]></icons>
	<message dir="ltr"><![CDATA[',$mjguest->entry->detail['message'],$mjguest->entry->detail['reply'],']]></message>
</entry>';
			
		break;
	}
	

	echo 
'</response>';	
	
	ob_end_flush();
	
	unset($mjguest);
?>
Return current item: MJGUEST