<?
require 'cp-includes/inc-confdata.php';
require 'cp-includes/inc-branding.php';
require 'cp-includes/inc-resource.php';
require 'cp-includes/inc-general.php';
require 'cp-includes/inc-functions.php';
require 'cp-includes/inc-secure.php';
if ($demo)
{
$dis = 'disabled=\'disabled\'';
}
else
{
$dis = '';
}
$page_titl = 'www.aaaaa.com';
$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 .= 'Моля избере <b> Потребител </b> за публикуване на обява<br/>';
}
if ($_POST[model_year])
{
if (!(ereg ('[0-9]{4}', $_POST[model_year])))
{
$error .= 'Моля напишете с числа<b> Година на строеж</b>.<br/>';
}
}
if (!($_POST[make]))
{
$error .= 'Моля изберете <b>Област</b> от падащото меню.<br/>';
}
if (!($_POST[model]))
{
$error .= 'Моля въведете <b>Град / Село </b>.<br/>';
}
if (!($_POST[cond]))
{
$error .= 'Моля изберете <b>Комисионна</b> от падащото меню..<br/>';
}
if (!($_POST[category]))
{
$error .= 'Моля изберете <b>Имот</b> от падащото меню.<br/>';
}
if (!($error))
{
if ($_POST[month])
{
if ($_POST[day])
{
if ($_POST[year])
{
$expire = mktime (1, 0, 0, $_POST[month], $_POST[day], $_POST[year]);
}
}
}
if ($_POST[mileage])
{
$_POST[mileage] = price ($_POST[mileage]);
}
if ($_POST[price])
{
$_POST[price] = price ($_POST[price]);
}
if ($_POST[sale])
{
$_POST[sale] = price ($_POST[sale]);
}
$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-summary.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>Въвеждане на нова обява</h1>
';
if ($error)
{
echo '<div id=\'msg-error\'>' . $error . '</div>';
}
echo '
<p>Задължителни полета (*)</p>
<form action=\'';
echo $_SERVER[PHP_SELF];
echo '\' method=\'post\'>
<div class=\'form alt\'>
<table border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td class=\'label\'><label for=\'userid\'>Лице за контакт: *</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) ' . $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\'>Валидна до:</label></td>
<td>
';
if ($expire)
{
echo ' <select name=\'month\' style=\'width:98px;\' tabindex=\'4\'>
<option value=\'\'></option>
';
for ($n = 1; $n <= 12; ++$n)
{
$month = date ('F', mktime (0, 0, 0, $n, 1, date ('Y')));
echo '<option value=\'' . $n . '\' ';
if ($n == $_POST[month])
{
echo 'избери';
}
echo '>' . $month . '</option>';
}
echo ' </select>
<select name=\'day\' style=\'width:45px;\' tabindex=\'5\'>
<option value=\'\'></option>
';
for ($n = 1; $n <= 31; ++$n)
{
echo '<option value=\'' . $n . '\' ';
if ($n == $_POST[day])
{
echo 'selected';
}
echo '>' . $n . '</option>';
}
echo ' </select>
<select name=\'year\' style=\'width:55px;\' tabindex=\'6\'>
<option value=\'\'></option>
';
for ($n = date ('Y') - 1; $n <= date ('Y') + 5; ++$n)
{
echo '<option value=\'' . $n . '\' ';
if ($n == $_POST[year])
{
echo 'selected';
}
echo '>' . $n . '</option>';
}
echo ' </select>
';
}
else
{
echo ' <i>Изключена опция</i>
';
}
echo ' </td>
</tr>
<tr>
<td><label for=\'location\'>Агенция: *</label></td>
<td>
<select class=\'widtha\' id=\'location\' name=\'location\' tabindex=\'2\'>
';
if ($_SESSION[c2][location])
{
$lrestrict = 'WHERE id=\'' . $_SESSION[c2][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 class=\'label\'><label for=\'featured\'>Топ обява:</label></td>
<td>
';
if ($feature)
{
echo ' <input class=\'check\' type=\'checkbox\' id=\'featured\' name=\'featured\' value=\'1\' ';
if ($_POST[featured])
{
echo 'checked="checked"';
}
echo ' tabindex=\'7\'/>
Маркирайте за Топ Обява
';
}
else
{
echo ' <i>Изключена опция</i>
';
}
echo ' </td>
</tr>
<tr>
<td><label for=\'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 class=\'label\'><label for=\'hide\'>Временно Спиране:</label></td>
<td>
';
if ($hide)
{
echo ' <input class=\'check\' type=\'checkbox\' id=\'hide\' name=\'hide\' value=\'1\' ';
if ($_POST[hide])
{
echo 'checked="checked"';
}
echo ' tabindex=\'8\'/>
Маркирай за временно спиране
';
}
else
{
echo ' <i>Изключена опция</i>
';
}
echo ' </td>
</tr>
</table>
</div>
<div class=\'form\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td class=\'label\'><label for=\'stock\'>Обява №:</label></td>
<td class=\'field\'><input class=\'widtha\' type=\'text\' id=\'stock\' name=\'stock\' value=\'';
echo $_POST[stock];
echo '\' tabindex=\'9\'/></td>
<td class=\'label\'><label for=\'category\'>Имот: *</label></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=\'vin\'>';
echo $conf[vin];
echo ':</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'vin\' name=\'vin\' value=\'';
echo $_POST[vin];
echo '\' tabindex=\'10\'/></td>
<td><label for=\'category2\'>Под директория:</label></td>
<td>
<select class=\'widtha\' id=\'category2\' name=\'category2\' tabindex=\'16\'>
<option value=\'\'> </option>
';
dropdown (explode ('
', $conf[categories]), $_POST[category2]);
echo ' </select>
</td>
</tr>
<tr>
<td><label for=\'model_year\'>Година на строеж:</label></td>
<td><input class=\'widthb\' type=\'text\' id=\'model_year\' name=\'model_year\' value=\'';
echo $_POST[model_year];
echo '\' maxlength=\'4\' tabindex=\'11\'/>
(';
echo date ('Y');
echo ')</td>
<td><label for=\'mileage\'>';
echo $conf[units];
echo ':</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'mileage\' name=\'mileage\' value=\'';
echo $_POST[mileage];
echo '\' tabindex=\'17\'/></td>
</tr>
<tr>
<td><label for=\'make\'>Област: *</label></td>
<td>
<select class=\'widtha\' id=\'make\' name=\'make\' tabindex=\'12\'>
<option value=\'\'> </option>
';
dropdown (explode ('
', $conf[makes]), $_POST[make]);
echo ' </select>
</td>
<td><label for=\'mileage_alt\'>Улица:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'mileage_alt\' name=\'mileage_alt\' value=\'';
echo $_POST[mileage_alt];
echo '\' tabindex=\'18\'/></td>
</tr>
<tr>
<td><label for=\'model\'>Град / Село: *</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'model\' name=\'model\' value=\'';
echo $_POST[model];
echo '\' tabindex=\'13\'/></td>
<td><label for=\'price\'>Цена:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'price\' name=\'price\' value=\'';
echo $_POST[price];
echo '\' tabindex=\'19\'/></td>
</tr>
<tr>
<td><label for=\'cond\'>Комисионна: *</label></td>
<td>
<select class=\'widtha\' id=\'cond\' name=\'cond\' tabindex=\'14\'>
<option value=\'\'> </option>
';
dropdown (explode ('
', $conf[conditions]), $_POST[cond]);
echo ' </select>
</td>
<td><label for=\'sale\'>Намалена цена:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'sale\' name=\'sale\' value=\'';
echo $_POST[sale];
echo '\' tabindex=\'20\'/></td>
</tr>
<tr>
<td></td>
<td></td>
<td><label for=\'price_alt\'>Друга Цена:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'price_alt\' name=\'price_alt\' value=\'';
echo $_POST[price_alt];
echo '\' tabindex=\'21\'/></td>
</tr>
</table>
</div>
<div class=\'form alt\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td class=\'label\'><label for=\'exterior\'>Статус:</label></td>
<td class=\'field\'><input class=\'widtha\' type=\'text\' id=\'exterior\' name=\'exterior\' value=\'';
echo $_POST[exterior];
echo '\' tabindex=\'22\'/></td>
<td class=\'label\'><label for=\'engine\'>Асансьор:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'engine\' name=\'engine\' value=\'';
echo $_POST[engine];
echo '\' tabindex=\'27\'/></td>
</tr>
<tr>
<td><label for=\'interior\'>Етаж:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'interior\' name=\'interior\' value=\'';
echo $_POST[interior];
echo '\' tabindex=\'23\'/></td>
<td><label for=\'trans\'>Състояние:</label></td>
<td>
<select class=\'widtha\' id=\'trans\' name=\'trans\' tabindex=\'28\'>
<option value=\'\'> </option>
';
dropdown (explode ('
', $conf[transmissions]), $_POST[trans]);
echo ' </select>
</td>
</tr>
<tr>
<td><label for=\'doors\'>Балкон / Тераси:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'doors\' name=\'doors\' value=\'';
echo $_POST[doors];
echo '\' tabindex=\'24\'/></td>
<td><label for=\'top_speed\'>Обзавеждане:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'top_speed\' name=\'top_speed\' value=\'';
echo $_POST[top_speed];
echo '\' tabindex=\'29\'/></td>
</tr>
<tr>
<td><label for=\'fuel\'>Отопление:</label></td>
<td>
<select class=\'widtha\' id=\'fuel\' name=\'fuel\' tabindex=\'25\'>
<option value=\'\'> </option>
';
dropdown (explode ('
', $conf[fuels]), $_POST[fuel]);
echo ' </select>
</td>
<td><label for=\'horsepower\'>Строителство:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'horsepower\' name=\'horsepower\' value=\'';
echo $_POST[horsepower];
echo '\' tabindex=\'30\'/></td>
</tr>
<tr>
<td><label for=\'drive\'>Гараж:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'drive\' name=\'drive\' value=\'';
echo $_POST[drive];
echo '\' tabindex=\'26\'/></td>
<td><label for=\'torque\'>Тежести върху имота:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'torque\' name=\'torque\' value=\'';
echo $_POST[torque];
echo '\' tabindex=\'31\'/></td>
</tr>
<tr>
<td></td>
<td></td>
<td><label for=\'towing\'>Лизинг:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'towing\' name=\'towing\' value=\'';
echo $_POST[towing];
echo '\' tabindex=\'32\'/></td>
</tr>
</table>
</div>
<div class=\'form\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td align=\'center\'>
';
$result = mysql_query ('SELECT * FROM ' . $dbcapt . ' ORDER BY caption ASC', $link);
if (mysql_num_rows ($result))
{
$cnt = mysql_num_rows ($result);
$num = ceil ($cnt / 3);
echo '<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'><tr><td style=\'text-align:left;\' width=\'34%\' valign=\'top\'>';
$n = 1;
while ($row = mysql_fetch_array ($result))
{
echo '<div class=\'check\'>';
echo '<input class=\'check\' type=\'checkbox\' id=\'cp' . $row['id'] . '\' name=\'cp' . $row['id'] . '\' value=\'1\'';
if ($_POST['cp' . $row['id']])
{
echo ' checked=\'checked\'';
}
echo '/>';
echo ' <label for=\'cp' . $row['id'] . '\'>' . $row['caption'] . '</label>';
echo '</div>';
if ($n % $num == 0)
{
if ($n < $cnt)
{
echo '</td><td style=\'text-align:left;\' width=\'33%\' valign=\'top\'>';
}
}
++$n;
}
echo '</td></tr></table>';
}
else
{
echo '';
}
echo '
</td>
</tr>
</table>
</div>
<div class=\'form alt\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td width=\'380\'><label for=\'features\'>Допълнително поле за екстри: </label></td>
<td><label for=\'description\'>Описание:</label></td>
</tr>
<tr>
<td><textarea class=\'widtha\' id=\'features\' name=\'features\'>';
echo $_POST[features];
echo '</textarea></td>
<td><textarea class=\'widtha\' id=\'description\' name=\'description\'>';
echo $_POST[description];
echo '</textarea></td>
</tr>
</table>
</div>
<div class=\'form\'>
<table width=\'100%\' border=\'0\' cellpadding=\'0\' cellspacing=\'0\'>
<tr>
<td class=\'label\'><label for=\'tagline\'>Ключови думи:</label></td>
<td><input class=\'widthc\' type=\'text\' id=\'tagline\' name=\'tagline\' value=\'';
echo $_POST[tagline];
echo '\' maxlength=\'200\'/></td>
</tr>
<tr>
<td class=\'label\'><label for=\'link_url\'>Допълнителна Интернет страница към имота:</label></td>
<td><input class=\'widthc\' type=\'text\' id=\'link_url\' name=\'link_url\' value=\'';
echo $_POST[link_url];
echo '\'/></td>
</tr>
<tr>
<td><label for=\'link_text\'>Текст към страницата:</label></td>
<td><input class=\'widtha\' type=\'text\' id=\'link_text\' name=\'link_text\' value=\'';
echo $_POST[link_text];
echo '\'/>
(Възможност до 25 символа)</td>
</tr>
<tr>
<td class=\'label\'><label for=\'ebay_url\'>Интернет страница в eBay Аукцион:</label></td>
<td><input class=\'widthc\' type=\'text\' id=\'ebay_url\' name=\'ebay_url\' value=\'';
echo $_POST[ebay_url];
echo '\'/></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=\'Въведи\' ';
echo $dis;
echo '/></td>
</tr>
</table>
</div>
</form>
</div>
';
require 'cp-includes/inc-footer.php';
?>