<?
if ($demo)
{
$dis = 'disabled=\'disabled\'';
}
else
{
$dis = '';
}
$page_titl = 'Add Listing';
$page_desc = '';
$page_keys = '';
$page_this = 'l';
$page_mode = 'la';
$page_subn = 'a';
$path_root = '';
$link = mysql_connect ($dbhost, $dbuser, $dbpass);
mysql_select_db ($dbname, $link);
$result = mysql_query ('SELECT * FROM ' . $dbconf, $link);
$conf = mysql_fetch_array ($result);
$conf = safe_data ($conf, 'display');
if ($_SESSION[c2][maxlist] <= $_SESSION[c2][listings])
{
if ($_SESSION[c2][maxlist] != 0)
{
header ('location:cp-list-index.php');
}
}
if ($_POST[submit])
{
if (!($demo))
{
$_POST = safe_data ($_POST, 'query');
if (!($_POST[userid]))
{
$error .= 'Please select a <b>User</b> to assign this listing to.<br/>';
}
if (!($_POST[make]))
{
$error .= 'Please select a <b>Make</b> for this listing.<br/>';
}
$result = mysql_query ('SELECT user_type,expire FROM ' . $dbacct . ' WHERE id=\'' . $_POST['userid'] . '\' LIMIT 1', $link);
$row = mysql_fetch_array ($result);
if (!(mysql_query ('INSERT INTO ' . $dblist . ' VALUES(\'0\',
\'' . $_POST['userid'] . '\',
\'' . $_POST['location'] . '\',
\'' . $row['type'] . '\',
\'' . time () . '\',
\'' . time () . ('\',
\'' . $expire . '\',
\'' . $row['expire'] . '\',
\'0\',
\'0\',
\'' . $_POST['hide'] . '\',
\'' . $_POST['featured'] . '\',
\'' . $_POST['status'] . '\',
\'1\',
\'' . $_POST['stock'] . '\',
\'' . $_POST['vin'] . '\',
\'' . $_POST['model_year'] . '\',
\'' . $_POST['make'] . '\',
\'' . $_POST['model'] . '\',
\'' . $_POST['cond'] . '\',
\'' . $_POST['category'] . '\',
\'' . $_POST['category2'] . '\',
\'' . $_POST['mileage'] . '\',
\'' . $_POST['mileage_alt'] . '\',
\'' . $_POST['price'] . '\',
\'' . $_POST['sale'] . '\',
\'' . $_POST['price_alt'] . '\',
\'' . $_POST['exterior'] . '\',
\'' . $_POST['interior'] . '\',
\'' . $_POST['doors'] . '\',
\'' . $_POST['fuel'] . '\',
\'' . $_POST['drive'] . '\',
\'' . $_POST['engine'] . '\',
\'' . $_POST['trans'] . '\',
\'' . $_POST['top_speed'] . '\',
\'' . $_POST['horsepower'] . '\',
\'' . $_POST['torque'] . '\',
\'' . $_POST['towing'] . '\',
\'' . $_POST['features'] . '\',
\'' . $_POST['description'] . '\',
\'' . $_POST['tagline'] . '\',
\'' . $_POST['link_url'] . '\',
\'' . $_POST['link_text'] . '\',
\'' . $_POST['ebay_url'] . '\')'), $link)))
{
exit (mysql_error ());
}
$listid = mysql_insert_id ($link);
if (!(mysql_query ('UPDATE ' . $dbacct . ' SET listings=listings+1 WHERE id=\'' . $_POST['userid'] . '\' LIMIT 1', $link)))
{
exit (mysql_error ());
}
if ($_POST[userid] == $_SESSION[c2][userid])
{
++$_SESSION[c2][listings];
}
if (!(mysql_query ('UPDATE ' . $dbloca . ' SET listings=listings+1 WHERE id=\'' . $_POST['location'] . '\' LIMIT 1', $link)))
{
exit (mysql_error ());
}
if (!(mysql_query ('INSERT INTO ' . $dbfeat . ' (id) VALUES(\'' . $listid . '\')', $link)))
{
exit (mysql_error ());
}
foreach ($_POST as $id => $value)
{
if (substr ($id, 0, 2) == 'cp')
{
if (!(mysql_query ('UPDATE ' . $dbfeat . ' SET ' . $id . '=\'' . $value . '\' WHERE id=\'' . $listid . '\' LIMIT 1', $link)))
{
exit (mysql_error ());
}
continue;
}
}
header ('location:cp-list-photos.php?id=' . $listid . '&add=true');
}
else
{
$_POST = safe_data ($_POST, 'display');
}
}
}
else
{
$_POST[userid] = $_SESSION[c2][userid];
$_POST[location] = $conf[location];
}
if ($_SESSION[c2][user_type] == 1)
{
if ($conf[user_mod])
{
$urestrict = '';
}
else
{
$urestrict = 'AND id=\'' . $_SESSION[c2][userid] . '\'';
}
}
else
{
if ($_SESSION[c2][user_type] == 2)
{
if ($conf[admin_mod])
{
$urestrict = '';
}
else
{
$urestrict = 'AND (id=\'' . $_SESSION[c2][userid] . '\' OR user_type=\'1\')';
}
}
else
{
$urestrict = '';
}
}
if ($_SESSION[c2][user_type] == 1)
{
if ($conf[user_expire])
{
$expire = true;
}
else
{
$expire = false;
}
}
else
{
if ($_SESSION[c2][user_type] == 2)
{
if ($conf[admin_expire])
{
$expire = true;
}
else
{
$expire = false;
}
}
else
{
$expire = true;
}
}
if ($_SESSION[c2][user_type] == 1)
{
if ($conf[user_feature])
{
$feature = true;
}
else
{
$feature = false;
}
}
else
{
if ($_SESSION[c2][user_type] == 2)
{
if ($conf[admin_feature])
{
$feature = true;
}
else
{
$feature = false;
}
}
else
{
$feature = true;
}
}
if ($_SESSION[c2][user_type] == 1)
{
if ($conf[user_hide])
{
$hide = true;
}
else
{
$hide = false;
}
}
else
{
if ($_SESSION[c2][user_type] == 2)
{
if ($conf[admin_hide])
{
$hide = true;
}
else
{
$hide = false;
}
}
else
{
$hide = true;
}
}
require 'cp-includes/inc-header.php';
require 'cp-includes/inc-navigation.php';
echo '
<div id=\'content\'>
<h1><span lang="ru"> </span></h1>
';
if ($error)
{
echo '<div id=\'msg-error\'>' . $error . '</div>';
}
echo '
<form action=\'';
echo $_SERVER[PHP_SELF];
echo '\' method=\'post\'>
<div class=\'form\'>
<table width=249 border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr style="display: none; visibility: hidden; ">
<td class=\'label\' colspan="2">
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\' id="table1">
<tr>
<td class=\'label\'><label for=\'userid\'>Assign Listing To: *</label></td>
<td class=\'field\'>
<select class=\'widtha\' id=\'userid\' name=\'userid\' tabindex=\'1\'>
';
$result = mysql_query ('SELECT id,CONCAT(first_name,\' \',last_name) AS name FROM ' . $dbacct . '
WHERE (maxlist=\'\' OR listings<maxlist OR id=\'' . $_POST['userid'] . '\') ' . $urestrict . ' ORDER BY name ASC', $link);
while ($row = mysql_fetch_array ($result))
{
$row = safe_data ($row, 'display');
echo '<option value=\'' . $row['id'] . '\'';
if ($row[id] == $_POST[userid])
{
echo ' selected=\'selected\'';
}
echo '>' . $row['name'] . '</option>';
}
echo ' </select>
</td>
<td class=\'label\'><label for=\'expire\'>Listing Expiration:</label></td>
</tr>
<tr>
<td><label for=\'location\'>Location: *</label></td>
<td>
<select class=\'widtha\' id=\'location\' name=\'location\' tabindex=\'2\'>
';
if ($_SESSION[c2][location])
{
$lrestrict = 'WHERE id=\'' . $_SESSION[c2][location] . ('\' OR id=\'' . $_POST['location'] . '\'');
}
$result = mysql_query ('SELECT id,name FROM ' . $dbloca . ' ' . $lrestrict . ' ORDER BY name ASC', $link);
while ($row = mysql_fetch_array ($result))
{
$row = safe_data ($row, 'display');
echo '<option value=\'' . $row['id'] . '\'';
if ($row[id] == $_POST[location])
{
echo ' selected=\'selected\'';
}
echo '>' . $row['name'] . '</option>';
}
echo ' </select>
</td>
<td><label for=\'featured\'>Feature this Listing:</label></td>
</tr>
<tr>
<td><label for=\'status\'>Listing Status: *</label></td>
<td>
<select class=\'widtha\' id=\'status\' name=\'status\' tabindex=\'3\'>
';
for ($n = 1; $n <= 3; ++$n)
{
echo '<option value=\'' . $n . '\'';
if ($n == $_POST[status])
{
echo ' selected=\'selected\'';
}
echo '>' . $status[$n] . '</option>';
}
echo ' </select>
</td>
<td><label for=\'hide\'>Hide this Listing:</label></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class=\'label\'><b><span lang="ru"> </span></b></td>
<td>
<select class=\'widtha\' id=\'category\' name=\'category\' tabindex=\'15\'>
<option value=\'\'> </option>
';
dropdown (explode ('
', $conf[categories]), $_POST[category]);
echo ' </select>
</td>
</tr>
<tr>
<td><label for=\'make\'><b> </b></label></td>
<td>
<input class=\'widthb\' type=\'text\' id=\'make\' name=\'make\' value=\'';
echo $_POST[make];
echo '\' maxlength=\'100\' tabindex=\'11\'/>
</td>
</tr>
</table>
</div>
<div class=\'form alt\'>
</div>
<div class=\'form alt\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td><label for="\'description\'"><b><span lang="ru"> </span></b>:</label></td>
</tr>
<tr>
<td><textarea class=\'widtha\' id=\'description\' name=\'description\'>';
echo $_POST[description];
echo '</textarea></td>
</tr>
</table>
</div>
<div class=\'form alt\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td align=\'center\'><input type=\'submit\' name=\'submit\' value=\'Submit Listing\' ';
echo $dis;
echo '/></td>
</tr>
</table>
</div>
</form>
</div>
';
require 'cp-includes/inc-footer.php';
?>