<?php

/* DCMS Special
 * Дата последнего редактирования 01.10.2016
 * Модифицировал densnet
 */


only_reg();


if (isset($_GET['ank'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['sex']) && ($_POST['sex'] == 1 || $_POST['sex'] == 0)) {
            $user['sex'] = intval($_POST['sex']);
            mysql_query("UPDATE `user` SET `sex` = '$user[sex]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Пол)');
        }

        if (isset($_POST['ank_surname']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['ank_surname'])) {
            $user['ank_surname'] = $_POST['ank_surname'];
            mysql_query("UPDATE `user` SET `ank_surname` = '" . mysql_real_escape_string($user['ank_surname']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат фамилии');
        }

        if (isset($_POST['ank_name']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['ank_name'])) {
            $user['ank_name'] = $_POST['ank_name'];
            mysql_query("UPDATE `user` SET `ank_name` = '" . mysql_real_escape_string($user['ank_name']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат имени');
        }

        if (isset($_POST['ank_patronymic']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['ank_patronymic'])) {
            $user['ank_patronymic'] = $_POST['ank_patronymic'];
            mysql_query("UPDATE `user` SET `ank_patronymic` = '" . mysql_real_escape_string($user['ank_patronymic']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат отчества');
        }

        if (isset($_POST['ank_d_r']) && (is_numeric($_POST['ank_d_r']) && $_POST['ank_d_r'] > 0 && $_POST['ank_d_r'] <= 31 || $_POST['ank_d_r'] == NULL)) {
            $user['ank_d_r'] = $_POST['ank_d_r'];

            if ($user['ank_d_r'] == null) {
                $user['ank_d_r'] = 'null';
            }

            mysql_query("UPDATE `user` SET `ank_d_r` = $user[ank_d_r] WHERE `id` = '$user[id]' LIMIT 1");

            if ($user['ank_d_r'] == 'null') {
                $user['ank_d_r'] = NULL;
            }
        } else {
            $err[] = lang('Неверный формат дня рождения');
        }

        if (isset($_POST['ank_m_r']) && (is_numeric($_POST['ank_m_r']) && $_POST['ank_m_r'] > 0 && $_POST['ank_m_r'] <= 12 || $_POST['ank_m_r'] == NULL)) {
            $user['ank_m_r'] = $_POST['ank_m_r'];

            if ($user['ank_m_r'] == null) {
                $user['ank_m_r'] = 'null';
            }

            mysql_query("UPDATE `user` SET `ank_m_r` = $user[ank_m_r] WHERE `id` = '$user[id]' LIMIT 1");

            if ($user['ank_m_r'] == 'null') {
                $user['ank_m_r'] = NULL;
            }
        } else {
            $err[] = lang('Неверный формат месяца рождения');
        }

        if (isset($_POST['ank_g_r']) && (is_numeric($_POST['ank_g_r']) && $_POST['ank_g_r'] > 0 && $_POST['ank_g_r'] <= date('Y') || $_POST['ank_g_r'] == NULL)) {
            $user['ank_g_r'] = $_POST['ank_g_r'];

            if ($user['ank_g_r'] == null) {
                $user['ank_g_r'] = 'null';
            }

            mysql_query("UPDATE `user` SET `ank_g_r` = $user[ank_g_r] WHERE `id` = '$user[id]' LIMIT 1");

            if ($user['ank_g_r'] == 'null') {
                $user['ank_g_r'] = NULL;
            }
        } else {
            $err[] = lang('Неверный формат года рождения');
        }

        if (isset($_POST['welcome']) && utf8_strlen($_POST['welcome']) <= 512) {
            $name = mysql_real_escape_string(trim($_POST['welcome']));
            $user['welcome'] = $_POST['welcome'];
            mysql_query("UPDATE `user` SET `welcome` = '" . $name . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Ошибка в статусе');
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location: /user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method='post' class='list-group-item-null' action=''>\n";

    $doc->Input('welcome', 'Статус', 150, "" . htmlspecialchars($user['welcome']) . "");
    $doc->Input('ank_name', 'Имя', 50, "" . toOutput($user['ank_name'], false) . "");
    $doc->Input('ank_surname', 'Фамилия', 100, "" . toOutput($user['ank_surname'], false) . "");
    $doc->Input('ank_patronymic', 'Отчество', 100, "" . toOutput($user['ank_patronymic'], false) . "");

    echo lang('Пол') . ":<br />";
    echo "<select class='form-control' name = 'sex'>";
    echo "<option value='1'" . ($user['sex'] == 1 ? " selected='selected'" : null) . ">" . lang('Мужской') . "</option>";
    echo "<option value='0'" . ($user['sex'] == 0 ? " selected='selected'" : null) . ">" . lang('Женский') . "</option>";
    echo "</select><br />";

    echo lang('Дата рождения') . ": " . lang('день/месяц/год') . "<br/>";

    echo "<input class='form-control' type='number' required name='ank_d_r' placeholder='01' value='$user[ank_d_r]' maxlength='2' /><br />";
    echo "<input class='form-control' type='number' required name='ank_m_r' placeholder='01' value='$user[ank_m_r]' maxlength='2' /><br />";
    echo "<input class='form-control' type='number' required name='ank_g_r' placeholder='1990' value='$user[ank_g_r]' maxlength='4' />";
    echo "<br />";

    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');

    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['ank_hair'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['ank_hair']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['ank_hair'])) {
            $user['ank_hair'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_hair']));
            mysql_query("UPDATE `user` SET `ank_hair` = '" . mysql_real_escape_string($user['ank_hair']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат цвет волос');
        }

        if (isset($_POST['ank_weight']) && (is_numeric($_POST['ank_weight']) && strlen($_POST['ank_weight']) >= 2 && strlen($_POST['ank_weight']) <= 11 || $_POST['ank_weight'] == NULL)) {
            $user['ank_weight'] = $_POST['ank_weight'];
            mysql_query("UPDATE `user` SET `ank_weight` = '$user[ank_weight]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат веса');
        }

        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 0) {
            $user['ank_physique'] = 0;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 0) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 1) {
            $user['ank_physique'] = 1;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 1) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 2) {
            $user['ank_physique'] = 2;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 2) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 3) {
            $user['ank_physique'] = 3;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 3) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 4) {
            $user['ank_physique'] = 4;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 4) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 5) {
            $user['ank_physique'] = 5;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 5) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_physique']) && $_POST['ank_physique'] == 6) {
            $user['ank_physique'] = 6;
            mysql_query("UPDATE `user` SET `ank_physique` = '" . ($user['ank_physique'] = 6) . "' WHERE `id` = '$user[id]'");
        }

        if (isset($_POST['ank_eye']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['ank_eye'])) {
            $user['ank_eye'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_eye']));
            mysql_query("UPDATE `user` SET `ank_eye` = '" . mysql_real_escape_string($user['ank_eye']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат цвет глаз');
        }

        if (isset($_POST['ank_height']) && (is_numeric($_POST['ank_height']) && strlen($_POST['ank_height']) >= 2 && strlen($_POST['ank_height']) <= 11 || $_POST['ank_height'] == NULL)) {
            $user['ank_height'] = $_POST['ank_height'];
            mysql_query("UPDATE `user` SET `ank_height` = '$user[ank_height]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат рост');
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method='post' class='list-group-item-null' action=''>\n";
    $doc->Input('ank_hair', 'Цвет волос', 100, "" . toOutput($user['ank_hair'], false) . "");
    $doc->Input('ank_eye', 'Цвет глаз', 100, "" . toOutput($user['ank_eye'], false) . "");

    echo lang('Телосложение') . ":<br />";
    $doc->Radio('ank_physique', 'Не скажу', '0', "" . ($user['ank_physique'] == 0 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_physique', 'Обычное', '1', "" . ($user['ank_physique'] == 1 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_physique', 'Худощавое', '2', "" . ($user['ank_physique'] == 2 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_physique', 'Спортивное', '3', "" . ($user['ank_physique'] == 3 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_physique', 'Мускулистое', '4', "" . ($user['ank_physique'] == 4 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_physique', 'Плотное', '5', "" . ($user['ank_physique'] == 5 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_physique', 'Полное', '6', "" . ($user['ank_physique'] == 6 ? " checked='checked'" : null) . "");

    echo lang('Рост') . ":<br />";
    echo '<select class="form-control" name="ank_height">
<option selected="' . $user['ank_height'] . '" value="' . $user['ank_height'] . '" >' . $user['ank_height'] . '</option>
<option value = "10" >' . lang('Не скажу') . '</option>
<option value = "80">80</option>
<option value = "81">81</option>
<option value = "82">82</option>
<option value = "83">83</option>
<option value = "84">84</option>
<option value = "85">85</option>
<option value = "86">86</option>
<option value = "87">87</option>
<option value = "88">88</option>
<option value = "89">89</option>
<option value = "90">90</option>
<option value = "91">91</option>
<option value = "92">92</option>
<option value = "93">93</option>
<option value = "94">94</option>
<option value = "95">95</option>
<option value = "96">96</option>
<option value = "97">97</option>
<option value = "98">98</option>
<option value = "99">99</option>
<option value = "100">100</option>
<option value = "101">101</option>
<option value = "102">102</option>
<option value = "103">103</option>
<option value = "104">104</option>
<option value = "105">105</option>
<option value = "106">106</option>
<option value = "107">107</option>
<option value = "108">108</option>
<option value = "109">109</option>
<option value = "110">110</option>
<option value = "111">111</option>
<option value = "112">112</option>
<option value = "113">113</option>
<option value = "114">114</option>
<option value = "115">115</option>
<option value = "116">116</option>
<option value = "117">117</option>
<option value = "118">118</option>
<option value = "119">119</option>
<option value = "120">120</option>
<option value = "121">121</option>
<option value = "122">122</option>
<option value = "123">123</option>
<option value = "124">124</option>
<option value = "125">125</option>
<option value = "126">126</option>
<option value = "127">127</option>
<option value = "128">128</option>
<option value = "129">129</option>
<option value = "130">130</option>
<option value = "131">131</option>
<option value = "132">132</option>
<option value = "133">133</option>
<option value = "134">134</option>
<option value = "135">135</option>
<option value = "136">136</option>
<option value = "137">137</option>
<option value = "138">138</option>
<option value = "139">139</option>
<option value = "140">140</option>
<option value = "141">141</option>
<option value = "142">142</option>
<option value = "143">143</option>
<option value = "144">144</option>
<option value = "145">145</option>
<option value = "146">146</option>
<option value = "147">147</option>
<option value = "148">148</option>
<option value = "149">149</option>
<option value = "150">150</option>
<option value = "151">151</option>
<option value = "152">152</option>
<option value = "153">153</option>
<option value = "154">154</option>
<option value = "155">155</option>
<option value = "156">156</option>
<option value = "157">157</option>
<option value = "158">158</option>
<option value = "159">159</option>
<option value = "160">160</option>
<option value = "161">161</option>
<option value = "162">162</option>
<option value = "163">163</option>
<option value = "164">164</option>
<option value = "165">165</option>
<option value = "166">166</option>
<option value = "167">167</option>
<option value = "168">168</option>
<option value = "169">169</option>
<option value = "170">170</option>
<option value = "171">171</option>
<option value = "172">172</option>
<option value = "173">173</option>
<option value = "174">174</option>
<option value = "175">175</option>
<option value = "176">176</option>
<option value = "177">177</option>
<option value = "178">178</option>
<option value = "179">179</option>
<option value = "180">180</option>
<option value = "181">181</option>
<option value = "182">182</option>
<option value = "183">183</option>
<option value = "184">184</option>
<option value = "185">185</option>
<option value = "186">186</option>
<option value = "187">187</option>
<option value = "188">188</option>
<option value = "189">189</option>
<option value = "190">190</option>
<option value = "191">191</option>
<option value = "192">192</option>
<option value = "193">193</option>
<option value = "194">194</option>
<option value = "195">195</option>
<option value = "196">196</option>
<option value = "197">197</option>
<option value = "198">198</option>
<option value = "199">199</option>
<option value = "200">200</option>
<option value = "201">201</option>
<option value = "202">202</option>
<option value = "203">203</option>
<option value = "204">204</option>
<option value = "205">205</option>
<option value = "206">206</option>
<option value = "207">207</option>
<option value = "208">208</option>
<option value = "209">209</option>
<option value = "210">210</option>
<option value = "211">211</option>
<option value = "212">212</option>
<option value = "213">213</option>
<option value = "214">214</option>
<option value = "215">215</option>
<option value = "216">216</option>
<option value = "217">217</option>
<option value = "218">218</option>
<option value = "219">219</option>
<option value = "220">220</option>
<option value = "221">221</option>
<option value = "222">222</option>
<option value = "223">223</option>
<option value = "224">224</option>
<option value = "225">225</option>
<option value = "226">226</option>
<option value = "227">227</option>
<option value = "228">228</option>
<option value = "229">229</option>
<option value = "230">230</option>
</select>';

    echo lang('Вес') . ":<br />";
    echo '<select class="form-control" name="ank_weight">
<option selected="' . $user['ank_weight'] . '" value="' . $user['ank_weight'] . '" >' . $user['ank_weight'] . '</option>
<option value = "10" >' . lang('Не скажу') . '</option>
<option value = "30">30</option>
<option value = "31">31</option>
<option value = "32">32</option>
<option value = "33">33</option>
<option value = "34">34</option>
<option value = "35">35</option>
<option value = "36">36</option>
<option value = "37">37</option>
<option value = "38">38</option>
<option value = "39">39</option>
<option value = "40">40</option>
<option value = "41">41</option>
<option value = "42">42</option>
<option value = "43">43</option>
<option value = "44">44</option>
<option value = "45">45</option>
<option value = "46">46</option>
<option value = "47">47</option>
<option value = "48">48</option>
<option value = "49">49</option>
<option value = "50">50</option>
<option value = "51">51</option>
<option value = "52">52</option>
<option value = "53">53</option>
<option value = "54">54</option>
<option value = "55">55</option>
<option value = "56">56</option>
<option value = "57">57</option>
<option value = "58">58</option>
<option value = "59">59</option>
<option value = "60">60</option>
<option value = "61">61</option>
<option value = "62">62</option>
<option value = "63">63</option>
<option value = "64">64</option>
<option value = "65">65</option>
<option value = "66">66</option>
<option value = "67">67</option>
<option value = "68">68</option>
<option value = "69">69</option>
<option value = "70">70</option>
<option value = "71">71</option>
<option value = "72">72</option>
<option value = "73">73</option>
<option value = "74">74</option>
<option value = "75">75</option>
<option value = "76">76</option>
<option value = "77">77</option>
<option value = "78">78</option>
<option value = "79">79</option>
<option value = "80">80</option>
<option value = "81">81</option>
<option value = "82">82</option>
<option value = "83">83</option>
<option value = "84">84</option>
<option value = "85">85</option>
<option value = "86">86</option>
<option value = "87">87</option>
<option value = "88">88</option>
<option value = "89">89</option>
<option value = "90">90</option>
<option value = "91">91</option>
<option value = "92">92</option>
<option value = "93">93</option>
<option value = "94">94</option>
<option value = "95">95</option>
<option value = "96">96</option>
<option value = "97">97</option>
<option value = "98">98</option>
<option value = "99">99</option>
<option value = "100">100</option>
<option value = "101">101</option>
<option value = "102">102</option>
<option value = "103">103</option>
<option value = "104">104</option>
<option value = "105">105</option>
<option value = "106">106</option>
<option value = "107">107</option>
<option value = "108">108</option>
<option value = "109">109</option>
<option value = "110">110</option>
<option value = "111">111</option>
<option value = "112">112</option>
<option value = "113">113</option>
<option value = "114">114</option>
<option value = "115">115</option>
<option value = "116">116</option>
<option value = "117">117</option>
<option value = "118">118</option>
<option value = "119">119</option>
<option value = "120">120</option>
<option value = "125">125</option>
<option value = "130">130</option>
<option value = "135">135</option>
<option value = "140">140</option>
<option value = "145">145</option>
<option value = "150">150</option>
<option value = "151">' . lang('Более') . ' 150</option>

</select><br />';


    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');

    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['country'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['region']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['region'])) {
            $user['region'] = $_POST['region'];
            mysql_query("UPDATE `user` SET `region` = '" . mysql_real_escape_string($user['region']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат Области (Края)');
        }
        if (isset($_POST['country']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['country'])) {
            $user['country'] = $_POST['country'];
            mysql_query("UPDATE `user` SET `country` = '" . mysql_real_escape_string($user['country']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат страны');
        }
        if (isset($_POST['ank_city']) && preg_match('#^([A-zА-я \-]*)$#ui', $_POST['ank_city'])) {
            $user['ank_city'] = $_POST['ank_city'];
            mysql_query("UPDATE `user` SET `ank_city` = '" . mysql_real_escape_string($user['ank_city']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат названия города');
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method = 'post' class = 'list-group-item-null' action = ''>\n";

    $doc->Input('country', 'Страна', 100, "$user[country]");
    $doc->Input('region', 'Область', 100, "$user[region]");
    $doc->Input('ank_city', 'Город', 100, "$user[ank_city]");

    echo "* Страну можно указать названием как русским так и английским. Внимательно посмотрите правильность написания Вашей страны, от этого зависит вывод флагов страны.";
    echo "<br />";

    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');

    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['love'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['ank_orientation']) && $_POST['ank_orientation'] == 0) {
            $user['ank_orientation'] = 0;
            mysql_query("UPDATE `user` SET `ank_orientation` = '" . ($user['ank_orientation'] = 0) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_orientation']) && $_POST['ank_orientation'] == 1) {
            $user['ank_orientation'] = 1;
            mysql_query("UPDATE `user` SET `ank_orientation` = '" . ($user['ank_orientation'] = 1) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_orientation']) && $_POST['ank_orientation'] == 2) {
            $user['ank_orientation'] = 2;
            mysql_query("UPDATE `user` SET `ank_orientation` = '" . ($user['ank_orientation'] = 2) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_orientation']) && $_POST['ank_orientation'] == 3) {
            $user['ank_orientation'] = 3;
            mysql_query("UPDATE `user` SET `ank_orientation` = '" . ($user['ank_orientation'] = 3) . "' WHERE `id` = '$user[id]'");
        }

        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 0) {
            $user['ank_marriage'] = 0;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 0) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 1) {
            $user['ank_marriage'] = 1;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 1) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 2) {
            $user['ank_marriage'] = 2;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 2) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 3) {
            $user['ank_marriage'] = 3;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 3) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 4) {
            $user['ank_marriage'] = 4;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 4) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 5) {
            $user['ank_marriage'] = 5;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 5) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 6) {
            $user['ank_marriage'] = 6;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 6) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 7) {
            $user['ank_marriage'] = 7;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 7) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 8) {
            $user['ank_marriage'] = 8;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 8) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 9) {
            $user['ank_marriage'] = 9;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 9) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 10) {
            $user['ank_marriage'] = 10;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 10) . "' WHERE `id` = '$user[id]'");
        }
        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 11) {
            $user['ank_marriage'] = 11;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 11) . "' WHERE `id` = '$user[id]'");
        }

        if (isset($_POST['ank_marriage']) && $_POST['ank_marriage'] == 12) {
            $user['ank_marriage'] = 12;
            mysql_query("UPDATE `user` SET `ank_marriage` = '" . ($user['ank_marriage'] = 12) . "' WHERE `id` = '$user[id]'");
        }

        if (isset($_POST['ank_goal_dating8']) && $_POST['ank_goal_dating8'] == 1) {

            $user['ank_goal_dating8'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating8` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating8'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating8` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }
        if (isset($_POST['ank_goal_dating7']) && $_POST['ank_goal_dating7'] == 1) {

            $user['ank_goal_dating7'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating7` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating7'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating7` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }
        if (isset($_POST['ank_goal_dating6']) && $_POST['ank_goal_dating6'] == 1) {

            $user['ank_goal_dating6'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating6` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating6'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating6` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (isset($_POST['ank_goal_dating5']) && $_POST['ank_goal_dating5'] == 1) {

            $user['ank_goal_dating5'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating5` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating5'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating5` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (isset($_POST['ank_goal_dating4']) && $_POST['ank_goal_dating4'] == 1) {

            $user['ank_goal_dating4'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating4` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating4'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating4` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (isset($_POST['ank_goal_dating3']) && $_POST['ank_goal_dating3'] == 1) {

            $user['ank_goal_dating3'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating3` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating3'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating3` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (isset($_POST['ank_goal_dating2']) && $_POST['ank_goal_dating2'] == 1) {

            $user['ank_goal_dating2'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating2` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating2'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating2` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (isset($_POST['ank_goal_dating']) && $_POST['ank_goal_dating'] == 1) {

            $user['ank_goal_dating'] = 1;
            mysql_query("UPDATE `user` SET `ank_goal_dating` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['ank_goal_dating'] = 0;
            mysql_query("UPDATE `user` SET `ank_goal_dating` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method = 'post' class = 'list-group-item-null' action = ''>\n";
    echo "<b>" . lang('Цель знакомств') . ":</b><br />";

    $doc->Checkbox('ank_goal_dating', 'Дружба и общение', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating2', 'Флирт, СМС-переписка', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating3', 'Любовь, отношения', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating4', 'Брак, создание семьи', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating5', 'Виртуальный секс', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating6', 'Секс в реале', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating7', 'Ищу спонсора', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");
    $doc->Checkbox('ank_goal_dating8', 'Стану спонсором', '1', "" . ($user['ank_goal_dating'] == 1 ? " checked='checked'" : null) . "");

    echo "<hr>";
    echo "<b>" . lang('Семейное положение') . ":</b><br />";

    $doc->Radio('ank_marriage', 'Не скажу', '0', "" . ($user['ank_marriage'] == 0 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Без пары', '1', "" . ($user['ank_marriage'] == 1 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Встречается', '2', "" . ($user['ank_marriage'] == 2 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Помолвлен-а', '3', "" . ($user['ank_marriage'] == 3 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'В браке', '4', "" . ($user['ank_marriage'] == 4 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'В гражданском браке', '5', "" . ($user['ank_marriage'] == 5 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'В домашнем партнерстве', '6', "" . ($user['ank_marriage'] == 6 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'В свободных отношениях', '7', "" . ($user['ank_marriage'] == 7 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Все сложно', '8', "" . ($user['ank_marriage'] == 8 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Раздельное проживание', '9', "" . ($user['ank_marriage'] == 9 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'В разводе', '10', "" . ($user['ank_marriage'] == 10 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Вдовец | Вдова', '11', "" . ($user['ank_marriage'] == 11 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_marriage', 'Влюблен-а', '12', "" . ($user['ank_marriage'] == 12 ? " checked='checked'" : null) . "");

    echo "<hr>";
    echo "<b>" . lang('Ориентация') . ":</b><br />";

    $doc->Radio('ank_orientation', 'Не скажу', '0', "" . ($user['ank_orientation'] == 0 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_orientation', 'Гетеро', '1', "" . ($user['ank_orientation'] == 1 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_orientation', 'Гей | Лезби', '2', "" . ($user['ank_orientation'] == 2 ? " checked='checked'" : null) . "");
    $doc->Radio('ank_orientation', 'Би', '3', "" . ($user['ank_orientation'] == 3 ? " checked='checked'" : null) . "");

    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');

    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['ank_hobbies'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['ank_music']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_music'])) {
            $user['ank_music'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_music']));
            mysql_query("UPDATE `user` SET `ank_music` = '" . mysql_real_escape_string($user['ank_music']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимая музыка');
        }

        if (isset($_POST['ank_activities']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_activities'])) {
            $user['ank_activities'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_activities']));
            mysql_query("UPDATE `user` SET `ank_activities` = '" . mysql_real_escape_string($user['ank_activities']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат деятельности');
        }

        if (isset($_POST['ank_films']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_films'])) {
            $user['ank_films'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_films']));
            mysql_query("UPDATE `user` SET `ank_films` = '" . mysql_real_escape_string($user['ank_films']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимый фильм');
        }

        if (isset($_POST['ank_teleshow']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_teleshow'])) {
            $user['ank_teleshow'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_teleshow']));
            mysql_query("UPDATE `user` SET `ank_teleshow` = '" . mysql_real_escape_string($user['ank_teleshow']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимые телешоу');
        }

        if (isset($_POST['ank_citates']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_citates'])) {
            $user['ank_citates'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_citates']));
            mysql_query("UPDATE `user` SET `ank_citates` = '" . mysql_real_escape_string($user['ank_citates']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимые цитаты');
        }

        if (isset($_POST['ank_games']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_games'])) {
            $user['ank_games'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_games']));
            mysql_query("UPDATE `user` SET `ank_games` = '" . mysql_real_escape_string($user['ank_games']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимые игры');
        }

        if (isset($_POST['ank_books']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_books'])) {
            $user['ank_books'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_books']));
            mysql_query("UPDATE `user` SET `ank_books` = '" . mysql_real_escape_string($user['ank_books']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимые книги');
        }

        if (isset($_POST['ank_passion']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_passion'])) {
            $user['ank_passion'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_passion']));
            mysql_query("UPDATE `user` SET `ank_passion` = '" . mysql_real_escape_string($user['ank_passion']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат увлечения');
        }

        if (isset($_POST['ank_course']) && preg_match('#^([0,1-9 A-zА-я \-]*)$#ui', $_POST['ank_course'])) {
            $user['ank_course'] = htmlspecialchars(mysql_real_escape_string($_POST['ank_course']));
            mysql_query("UPDATE `user` SET `ank_course` = '" . mysql_real_escape_string($user['ank_course']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат любимое блюдо');
        }

        if (isset($_POST['ank_about_me']) && utf8_strlen($_POST['ank_about_me']) <= 512) {
            if (preg_match('#[^A-zА-я0-9 _\-\=\+\(\)\*\?\.,]#ui', $_POST['ank_about_me'])) {
                $err[] = lang('В поле "О себе" используются запрещенные символы');
            } else {
                $user['ank_about_me'] = $_POST['ank_about_me'];
                mysql_query("UPDATE `user` SET `ank_about_me` = '" . mysql_real_escape_string($user['ank_about_me']) . "' WHERE `id` = '$user[id]' LIMIT 1");
            }
        } else {
            $err[] = lang('Ошибка в поле (О себе)');
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method='post' class='list-group-item-null' action=''>\n";

    $doc->Textarea('ank_music', 'Любимая музыка', 512, "" . toOutput($user['ank_music'], false) . "");
    $doc->Textarea('ank_films', 'Любимые фильмы', 512, "" . toOutput($user['ank_films'], false) . "");
    $doc->Textarea('ank_teleshow', 'Любимые телешоу', 512, "" . toOutput($user['ank_teleshow'], false) . "");
    $doc->Textarea('ank_books', 'Любимые книги', 512, "" . toOutput($user['ank_books'], false) . "");
    $doc->Textarea('ank_games', 'Любимые игры', 512, "" . toOutput($user['ank_games'], false) . "");
    $doc->Textarea('ank_citates', 'Любимые цитаты', 512, "" . toOutput($user['ank_citates'], false) . "");
    $doc->Textarea('ank_course', 'Любимое блюдо', 512, "" . toOutput($user['ank_course'], false) . "");
    echo "<small><font color = 'grey'>(Участие в организациях, общественные посты)</font></small><br />";
    $doc->Textarea('ank_activities', 'Деятельность', 512, "" . toOutput($user['ank_activities'], false) . "");
    $doc->Textarea('ank_passion', 'Интересы', 512, "" . toOutput($user['ank_passion'], false) . "");
    $doc->Textarea('ank_about_me', 'О себе', 512, "" . toOutput($user['ank_about_me'], false) . "");
    echo "<br />";
    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');
    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['ank_profession'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['ank_profession'])) {
            $user['ank_profession'] = $_POST['ank_profession'];
            mysql_query("UPDATE `user` SET `ank_profession` = '" . mysql_real_escape_string($user['ank_profession']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method = 'post' class = 'list-group-item-null' action = ''>\n";

    $doc->Textarea('ank_profession', 'Профессиональные навыки', 512, "" . toOutput($user['ank_profession'], false) . "");
    echo "<br />";
    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');
    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['ank_inspiration'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['ank_inspiration'])) {
            $user['ank_inspiration'] = $_POST['ank_inspiration'];
            mysql_query("UPDATE `user` SET `ank_inspiration` = '" . mysql_real_escape_string($user['ank_inspiration']) . "' WHERE `id` = '$user[id]' LIMIT 1");
        }

        if (isset($_POST['ank_political']) && (
                $_POST['ank_political'] == 0 ||
                $_POST['ank_political'] == 1 ||
                $_POST['ank_political'] == 2 ||
                $_POST['ank_political'] == 3 ||
                $_POST['ank_political'] == 4 ||
                $_POST['ank_political'] == 5 ||
                $_POST['ank_political'] == 6 ||
                $_POST['ank_political'] == 7 ||
                $_POST['ank_political'] == 8 ||
                $_POST['ank_political'] == 9)) {
            $user['ank_political'] = intval($_POST['ank_political']);
            mysql_query("UPDATE `user` SET `ank_political` = '$user[ank_political]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Полит. предпочтения)');
        }

        if (isset($_POST['ank_world_view']) && (
                $_POST['ank_world_view'] == 0 ||
                $_POST['ank_world_view'] == 1 ||
                $_POST['ank_world_view'] == 2 ||
                $_POST['ank_world_view'] == 3 ||
                $_POST['ank_world_view'] == 4 ||
                $_POST['ank_world_view'] == 5 ||
                $_POST['ank_world_view'] == 6 ||
                $_POST['ank_world_view'] == 7 ||
                $_POST['ank_world_view'] == 8 ||
                $_POST['ank_world_view'] == 9)) {
            $user['ank_world_view'] = intval($_POST['ank_world_view']);
            mysql_query("UPDATE `user` SET `ank_world_view` = '$user[ank_world_view]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Мировоззрение)');
        }

        if (isset($_POST['ank_important_life']) && (
                $_POST['ank_important_life'] == 0 ||
                $_POST['ank_important_life'] == 1 ||
                $_POST['ank_important_life'] == 2 ||
                $_POST['ank_important_life'] == 3 ||
                $_POST['ank_important_life'] == 4 ||
                $_POST['ank_important_life'] == 5 ||
                $_POST['ank_important_life'] == 6 ||
                $_POST['ank_important_life'] == 7 ||
                $_POST['ank_important_life'] == 8)) {
            $user['ank_important_life'] = intval($_POST['ank_important_life']);
            mysql_query("UPDATE `user` SET `ank_important_life` = '$user[ank_important_life]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Главное в жизни)');
        }

        if (isset($_POST['ank_important_people']) && (
                $_POST['ank_important_people'] == 0 ||
                $_POST['ank_important_people'] == 1 ||
                $_POST['ank_important_people'] == 2 ||
                $_POST['ank_important_people'] == 3 ||
                $_POST['ank_important_people'] == 4 ||
                $_POST['ank_important_people'] == 5 ||
                $_POST['ank_important_people'] == 6)) {
            $user['ank_important_people'] = intval($_POST['ank_important_people']);
            mysql_query("UPDATE `user` SET `ank_important_people` = '$user[ank_important_people]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Главное в людях)');
        }

        if (isset($_POST['ank_smoking']) && (
                $_POST['ank_smoking'] == 0 ||
                $_POST['ank_smoking'] == 1 ||
                $_POST['ank_smoking'] == 2 ||
                $_POST['ank_smoking'] == 3 ||
                $_POST['ank_smoking'] == 4 ||
                $_POST['ank_smoking'] == 5)) {
            $user['ank_smoking'] = intval($_POST['ank_smoking']);
            mysql_query("UPDATE `user` SET `ank_smoking` = '$user[ank_smoking]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Отношение к курению)');
        }

        if (isset($_POST['ank_alcohol']) && (
                $_POST['ank_alcohol'] == 0 ||
                $_POST['ank_alcohol'] == 1 ||
                $_POST['ank_alcohol'] == 2 ||
                $_POST['ank_alcohol'] == 3 ||
                $_POST['ank_alcohol'] == 4 ||
                $_POST['ank_alcohol'] == 5)) {
            $user['ank_alcohol'] = intval($_POST['ank_alcohol']);
            mysql_query("UPDATE `user` SET `ank_alcohol` = '$user[ank_alcohol]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err = lang('Ошибка в поле (Отношение к алкоголю)');
        }


        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method = 'post' class = 'list-group-item-null' action = ''>\n";

    echo lang('Полит. предпочтения') . ":<br />";

    echo "<select class='form-control' name='ank_political'>";
    echo "<option value = '0'" . ($user['ank_political'] == 0 ? " selected = 'selected'" : null) . "> - " . lang('Не выбрано') . " - </option>";
    echo "<option value = '1'" . ($user['ank_political'] == 1 ? " selected = 'selected'" : null) . ">" . lang('Индифферентные') . "</option>";
    echo "<option value = '2'" . ($user['ank_political'] == 2 ? " selected = 'selected'" : null) . ">" . lang('Коммунистические') . "</option>";
    echo "<option value = '3'" . ($user['ank_political'] == 3 ? " selected = 'selected'" : null) . ">" . lang('Социалистические') . "</option>";
    echo "<option value = '4'" . ($user['ank_political'] == 4 ? " selected = 'selected'" : null) . ">" . lang('Умеренные') . "</option>";
    echo "<option value = '5'" . ($user['ank_political'] == 5 ? " selected = 'selected'" : null) . ">" . lang('Либеральные') . "</option>";
    echo "<option value = '6'" . ($user['ank_political'] == 6 ? " selected = 'selected'" : null) . ">" . lang('Консервативные') . "</option>";
    echo "<option value = '7'" . ($user['ank_political'] == 7 ? " selected = 'selected'" : null) . ">" . lang('Монархические') . "</option>";
    echo "<option value = '8'" . ($user['ank_political'] == 8 ? " selected = 'selected'" : null) . ">" . lang('Ультраконсервативные') . "</option>";
    echo "<option value = '9'" . ($user['ank_political'] == 9 ? " selected = 'selected'" : null) . ">" . lang('Либертарианские') . "</option>";
    echo "</select>";

    echo lang('Мировоззрение') . ":<br />";
    echo "<select class='form-control' name = 'ank_world_view'>";
    echo "<option value = '0'" . ($user['ank_world_view'] == 0 ? " selected = 'selected'" : null) . "> - " . lang('Не выбрано') . " - </option>";
    echo "<option value = '1'" . ($user['ank_world_view'] == 1 ? " selected = 'selected'" : null) . ">" . lang('Иудаизм') . "</option>";
    echo "<option value = '2'" . ($user['ank_world_view'] == 2 ? " selected = 'selected'" : null) . ">" . lang('Православие') . "</option>";
    echo "<option value = '3'" . ($user['ank_world_view'] == 3 ? " selected = 'selected'" : null) . ">" . lang('Католицизм') . "</option>";
    echo "<option value = '4'" . ($user['ank_world_view'] == 4 ? " selected = 'selected'" : null) . ">" . lang('Протестантизм') . "</option>";
    echo "<option value = '5'" . ($user['ank_world_view'] == 5 ? " selected = 'selected'" : null) . ">" . lang('Ислам') . "</option>";
    echo "<option value = '6'" . ($user['ank_world_view'] == 6 ? " selected = 'selected'" : null) . ">" . lang('Буддизм') . "</option>";
    echo "<option value = '7'" . ($user['ank_world_view'] == 7 ? " selected = 'selected'" : null) . ">" . lang('Конфуцианство') . "</option>";
    echo "<option value = '8'" . ($user['ank_world_view'] == 8 ? " selected = 'selected'" : null) . ">" . lang('Светский гуманизм') . "</option>";
    echo "<option value = '9'" . ($user['ank_world_view'] == 9 ? " selected = 'selected'" : null) . ">" . lang('Пастафарианство') . "</option>";
    echo "</select>";

    echo "<label>" . lang('Главное в жизни') . ":</label>";
    echo "<select class='form-control' name = 'ank_important_life'>";
    echo "<option value = '0'" . ($user['ank_important_life'] == 0 ? " selected = 'selected'" : null) . "> - " . lang('Не выбрано') . " - </option>";
    echo "<option value = '1'" . ($user['ank_important_life'] == 1 ? " selected = 'selected'" : null) . ">" . lang('Семья и дети') . "</option>";
    echo "<option value = '2'" . ($user['ank_important_life'] == 2 ? " selected = 'selected'" : null) . ">" . lang('Карьера и деньги') . "</option>";
    echo "<option value = '3'" . ($user['ank_important_life'] == 3 ? " selected = 'selected'" : null) . ">" . lang('Развлечения и отдых') . "</option>";
    echo "<option value = '4'" . ($user['ank_important_life'] == 4 ? " selected = 'selected'" : null) . ">" . lang('Наука и исследования') . "</option>";
    echo "<option value = '5'" . ($user['ank_important_life'] == 5 ? " selected = 'selected'" : null) . ">" . lang('Совершенствование мира') . "</option>";
    echo "<option value = '6'" . ($user['ank_important_life'] == 6 ? " selected = 'selected'" : null) . ">" . lang('Саморазвитие') . "</option>";
    echo "<option value = '7'" . ($user['ank_important_life'] == 7 ? " selected = 'selected'" : null) . ">" . lang('Красота и искусство') . "</option>";
    echo "<option value = '8'" . ($user['ank_important_life'] == 8 ? " selected = 'selected'" : null) . ">" . lang('Слава и влияние') . "</option>";
    echo "</select>";

    echo "<label>" . lang('Главное в людях') . ":</label>";
    echo "<select class='form-control' name = 'ank_important_people'>";
    echo "<option value = '0'" . ($user['ank_important_people'] == 0 ? " selected = 'selected'" : null) . "> - " . lang('Не выбрано') . " - </option>";
    echo "<option value = '1'" . ($user['ank_important_people'] == 1 ? " selected = 'selected'" : null) . ">" . lang('Ум и креативность') . "</option>";
    echo "<option value = '2'" . ($user['ank_important_people'] == 2 ? " selected = 'selected'" : null) . ">" . lang('Доброта и честность') . "</option>";
    echo "<option value = '3'" . ($user['ank_important_people'] == 3 ? " selected = 'selected'" : null) . ">" . lang('Красота и здоровье') . "</option>";
    echo "<option value = '4'" . ($user['ank_important_people'] == 4 ? " selected = 'selected'" : null) . ">" . lang('Власть и богатство') . "</option>";
    echo "<option value = '5'" . ($user['ank_important_people'] == 5 ? " selected = 'selected'" : null) . ">" . lang('Смелость и упорство') . "</option>";
    echo "<option value = '6'" . ($user['ank_important_people'] == 6 ? " selected = 'selected'" : null) . ">" . lang('Юмор и жизнелюбие') . "</option>";
    echo "</select>";

    echo "<label>" . lang('Отношение к курению') . ":</label>";
    echo "<select class='form-control' name = 'ank_smoking'>";
    echo "<option value = '0'" . ($user['ank_smoking'] == 0 ? " selected = 'selected'" : null) . "> - " . lang('Не выбрано') . " - </option>";
    echo "<option value = '1'" . ($user['ank_smoking'] == 1 ? " selected = 'selected'" : null) . ">" . lang('Резко негативное') . "</option>";
    echo "<option value = '2'" . ($user['ank_smoking'] == 2 ? " selected = 'selected'" : null) . ">" . lang('Негативное') . "</option>";
    echo "<option value = '3'" . ($user['ank_smoking'] == 3 ? " selected = 'selected'" : null) . ">" . lang('Компромиссное') . "</option>";
    echo "<option value = '4'" . ($user['ank_smoking'] == 4 ? " selected = 'selected'" : null) . ">" . lang('Нейтральное') . "</option>";
    echo "<option value = '5'" . ($user['ank_smoking'] == 5 ? " selected = 'selected'" : null) . ">" . lang('Положительное') . "</option>";
    echo "</select>";

    echo "<label>" . lang('Отношение к алкоголю') . ":</label>";
    echo "<select class='form-control' name = 'ank_alcohol'>";
    echo "<option value = '0'" . ($user['ank_alcohol'] == 0 ? " selected = 'selected'" : null) . "> - " . lang('Не выбрано') . " - </option>";
    echo "<option value = '1'" . ($user['ank_alcohol'] == 1 ? " selected = 'selected'" : null) . ">" . lang('Резко негативное') . "</option>";
    echo "<option value = '2'" . ($user['ank_alcohol'] == 2 ? " selected = 'selected'" : null) . ">" . lang('Негативное') . "</option>";
    echo "<option value = '3'" . ($user['ank_alcohol'] == 3 ? " selected = 'selected'" : null) . ">" . lang('Компромиссное') . "</option>";
    echo "<option value = '4'" . ($user['ank_alcohol'] == 4 ? " selected = 'selected'" : null) . ">" . lang('Нейтральное') . "</option>";
    echo "<option value = '5'" . ($user['ank_alcohol'] == 5 ? " selected = 'selected'" : null) . ">" . lang('Положительное') . "</option>";
    echo "</select>";

    $doc->Input('ank_inspiration', 'Источники вдохновения', 512, "" . toOutput($user['ank_inspiration'], false) . "");
    echo "<br />";
    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');
    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}

if (isset($_GET['ank_icq'])) {
    if (isset($_POST['save'])) {

        if (isset($_POST['ank_icq']) && (is_numeric($_POST['ank_icq']) && strlen($_POST['ank_icq']) >= 5 && strlen($_POST['ank_icq']) <= 9 || $_POST['ank_icq'] == NULL)) {
            $user['ank_icq'] = $_POST['ank_icq'];
            if ($user['ank_icq'] == null) {
                $user['ank_icq'] = 'null';
            }
            mysql_query("UPDATE `user` SET `ank_icq` = $user[ank_icq] WHERE `id` = '$user[id]' LIMIT 1");
            if ($user['ank_icq'] == 'null') {
                $user['ank_icq'] = NULL;
            }
        } else {
            $err[] = lang('Неверный формат ICQ');
        }

        if (isset($_POST['set_show_mail']) && $_POST['set_show_mail'] == 1) {
            $user['set_show_mail'] = 1;
            mysql_query("UPDATE `user` SET `set_show_mail` = '1' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $user['set_show_mail'] = 0;
            mysql_query("UPDATE `user` SET `set_show_mail` = '0' WHERE `id` = '$user[id]' LIMIT 1");
        }
        if (isset($_POST['ank_n_tel']) && (is_numeric($_POST['ank_n_tel']) && strlen($_POST['ank_n_tel']) >= 5 && strlen($_POST['ank_n_tel']) <= 12 || $_POST['ank_n_tel'] == NULL)) {
            $user['ank_n_tel'] = $_POST['ank_n_tel'];
            mysql_query("UPDATE `user` SET `ank_n_tel` = '$user[ank_n_tel]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат номера телефона (моб)');
        }
        if (isset($_POST['ank_mail']) && ($_POST['ank_mail'] == null || preg_match('#^[a-z0-9\-\._]+\@([a-z0-9]+\.)+([a-z0-9]{2,4})$#ui', $_POST['ank_mail']))) {
            $user['ank_mail'] = $_POST['ank_mail'];
            mysql_query("UPDATE `user` SET `ank_mail` = '$user[ank_mail]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = 'Неверный E-mail';
        }
        if (isset($_POST['ank_n_tel_home']) && (is_numeric($_POST['ank_n_tel_home']) && strlen($_POST['ank_n_tel_home']) >= 5 && strlen($_POST['ank_n_tel_home']) <= 12 || $_POST['ank_n_tel_home'] == NULL)) {
            $user['ank_n_tel_home'] = $_POST['ank_n_tel_home'];
            mysql_query("UPDATE `user` SET `ank_n_tel_home` = '$user[ank_n_tel_home]' WHERE `id` = '$user[id]' LIMIT 1");
        } else {
            $err[] = lang('Неверный формат номера телефона (дом)');
        }

        if (!isset($err)) {
            $_SESSION['message'] = lang('Изменения сохранены');
            header("Location:/user/anketa/?name=$ank[nick]");
        }
    }
    err();

    echo "<form method='post' class='list-group-item-null' action=''>\n";

    $doc->Input('ank_icq', 'ICQ', 9, "$user[ank_icq]");
    $doc->Checkbox('set_show_mail', 'Показывать в анкете', '1', "" . ($user['set_show_mail'] == 1 ? " checked='checked'" : null) . "");
    $doc->Input('ank_mail', 'E-mail', 32, "$user[ank_mail]");
    $doc->Input('ank_n_tel', 'Номер телефона (моб)', 12, "$user[ank_n_tel]");
    $doc->Input('ank_n_tel_home', 'Номер телефона (дом)', 12, "$user[ank_n_tel_home]");
    echo "<br />";
    $doc->Button('btn btn-success btn-sm', 'save', 'save', 'Сохранить');
    echo "</form>";

    $doc->Link('list-group-item-null', "/user/anketa/?name=$ank[nick]", 'arrow-left', 'Назад');

    require_once H . 'sys/inc/tfoot.php';
    exit;
}