File: /home/mckernan/public_html/iJournal/includes/client/inccats.php
<?php
// income categories
// init database name
$database = DB_PREFIX;
// process request
if ($sid != '')
{
// sid check
require "includes/session/sidck.php";
// init return value
$rv = '<root>' . PHP_EOL;
$rv .= '<cats>' . PHP_EOL;
// fetch database name / open db
$db = '';
if ( isset($_POST['db']) ) $db = $_POST['db'];
if ( isset($_GET['db']) ) $db = $_GET['db'];
if ($db == '') die();
$database .= $db;
require "includes/db.php";
// fetch client info
$query = "SELECT in_gross, in_hascogs, in_cogs, in_0, in_1, in_2, in_3 FROM categories";
if ($result = $db->query($query))
{
if ($db->affected_rows == 1)
{
$row = $result->fetch_assoc();
$rv .= '<gross>' . $row['in_gross'] . '</gross>' . PHP_EOL;
$rv .= '<hascogs>' . $row['in_hascogs'] . '</hascogs>' . PHP_EOL;
$rv .= '<cogs>' . $row['in_cogs'] . '</cogs>' . PHP_EOL;
$rv .= '<other0>' . $row['in_0'] . '</other0>' . PHP_EOL;
$rv .= '<other1>' . $row['in_1'] . '</other1>' . PHP_EOL;
$rv .= '<other2>' . $row['in_2'] . '</other2>' . PHP_EOL;
$rv .= '<other3>' . $row['in_3'] . '</other3>' . PHP_EOL;
}
else
{
$rv .= '<gross></gross>' . PHP_EOL;
$rv .= '<hascogs>0</hascogs>' . PHP_EOL;
$rv .= '<cogs></cogs>' . PHP_EOL;
$rv .= '<other0></other0>' . PHP_EOL;
$rv .= '<other1></other1>' . PHP_EOL;
$rv .= '<other2></other2>' . PHP_EOL;
$rv .= '<other3></other3>' . PHP_EOL;
}
}
else
{
$rv .= '<gross></gross>' . PHP_EOL;
$rv .= '<hascogs>0</hascogs>' . PHP_EOL;
$rv .= '<cogs></cogs>' . PHP_EOL;
$rv .= '<other0></other0>' . PHP_EOL;
$rv .= '<other1></other1>' . PHP_EOL;
$rv .= '<other2></other2>' . PHP_EOL;
$rv .= '<other3></other3>' . PHP_EOL;
}
// finish output
$rv .= '</cats>' . PHP_EOL;
$rv .= '</root>' . PHP_EOL;
// return data
echo $rv;
die;
}
else
{
header('Server: ');
header('X-Powered-By: ');
header("HTTP/1.0 404 Not Found");
}
?>