{"id":270776,"date":"2015-12-21T12:10:02","date_gmt":"2015-12-21T09:10:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=270776"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=270776","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043b\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0438 \u043d\u0430 php\/mysql \u0441 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435"},"content":{"rendered":"<p>       \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a!<\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u043d\u0435\u0432\u043d\u0438\u043a\u0430, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435\u043c \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c <s>\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434<\/s> \u043b\u0438\u0447\u043d\u044b\u0439 \u0434\u043d\u0435\u0432\u043d\u0438\u043a (\u0437\u0430\u043f\u0438\u0441\u043d\u0443\u044e \u043a\u043d\u0438\u0436\u043a\u0443) \u043d\u0430 php \u0438 mysql \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 php-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u043b\u044e\u0434\u0438 \u044d\u0442\u043e \u0432\u0441\u0451 \u0437\u043d\u0430\u044e\u0442 \u0438 \u0441\u0434\u0435\u043b\u0430\u044e\u0442 \u0432\u0441\u0451 \u044d\u0442\u043e \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u043c\u0435\u043d\u044f.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0438 \u2014 \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0430 \u043a\u043b\u044e\u0447 \u0437\u043d\u0430\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0443\u043a\u0440\u0430\u0434\u0451\u0442 \u0432\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0447\u0442\u043e \u043e\u043d \u0443\u0432\u0438\u0434\u0438\u0442:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f60\/12b\/7e6\/f6012b7e613e4fb09a8ac089bbfd4bd3.png\"\/><br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u041b\u0438\u0447\u043d\u044b\u0439 \u0434\u043d\u0435\u0432\u043d\u0438\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 php \u043a\u043b\u0430\u0441\u0441\u0430  <\/p>\n<ul>\n<li><a href=\"https:\/\/bitbucket.org\/pingvi\/personal_diary\/src\/e7d43bb63836255392f9f774ac92aec0c0d92a2e\/xtea.php?at=master&amp;fileviewer=file-view-default\">XTEA<\/a> \u2014 \u0434\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/li>\n<li><a href=\"https:\/\/bitbucket.org\/pingvi\/personal_diary\/src\/e7d43bb63836255392f9f774ac92aec0c0d92a2e\/db.php?at=master&amp;fileviewer=file-view-default\">SafeMySQL<\/a> \u2014 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<\/ul>\n<p>  \u0418\u043c\u0435\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<br \/>  <code> CREATE TABLE `notest` ( `id` int(255) NOT NULL,   `text` text NOT NULL,   `date_d` text NOT NULL,   `date_m` text NOT NULL,   `date_t` text NOT NULL,   `date_cat` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; <\/code><\/p>\n<p>  \u041a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 $_SESSION[&#8216;key&#8217;]<br \/>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0451 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a\u043b\u044e\u0447, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0442  <\/p>\n<pre><code class=\"php\">\/\/ \u0415\u0441\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u043b\u044e\u0447\u0430   if (!isset($_SESSION['key'])) {     $keyw = '&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;key&quot; placeholder=&quot;\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448 \u043a\u043b\u044e\u0447&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&quot;&gt;&lt;\/form&gt;';   }   \/\/ \u0418\u043d\u0430\u0447\u0435, \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   else {     $keyw = '&lt;button&gt;&lt;a class=&quot;nodec_link&quot; href=&quot;index.php?action=delkey&quot;&gt;\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043b\u044e\u0447&lt;\/a&gt;&lt;\/button&gt;';   }   \/\/ \u0415\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u0444\u043e\u0440\u043c\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430   if (isset($_POST[&quot;key&quot;])) {     $_SESSION['key'] = $_POST[&quot;key&quot;];     header(&quot;Location: index.php&quot;);     exit();   } <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u0443, \u0434\u0435\u043b\u0430\u0435\u043c unset  <\/p>\n<pre><code class=\"php\">if ((isset($_GET['action'])) && ($_GET['action'] == 'delkey')) {     unset($_SESSION['key']);     header(&quot;Location: index.php&quot;);     exit();   } <\/code><\/pre>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445, \u043d\u043e \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u043e \u043c\u0435\u0441\u044f\u0446\u0430\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438  <\/p>\n<pre><code class=\"php\">$db = new SafeMySQL($set_bd); $option = $db-&gt;getAll(&quot;SELECT DISTINCT `date_cat` FROM `notes`&quot;); foreach ($option as $value) { $desc_opt = explode(&quot;-&quot;, $value['date_cat']);  echo '&lt;option value=&quot;index.php?date='.$value['date_cat'].'&quot;&gt;'.num2name($desc_opt[0]).' '.$desc_opt[1].'&lt;\/option&gt;'; } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f num2name() \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043d\u043e\u043c\u0435\u0440 \u043c\u0435\u0441\u044f\u0446\u0430 \u0432 \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">function num2name($num) {     switch ($num) {       case '01':         $name = &quot;\u044f\u043d\u0432\u0430\u0440\u044c&quot;;         break;       case '02':         $name = &quot;\u0444\u0435\u0432\u0440\u0430\u043b\u044c&quot;;         break;       case '03':         $name = &quot;\u043c\u0430\u0440\u0442&quot;;         break;       case '04':         $name = &quot;\u0430\u043f\u0440\u0435\u043b\u044c&quot;;         break;       case '05':         $name = &quot;\u043c\u0430\u0439&quot;;         break;       case '06':         $name = &quot;\u0438\u044e\u043d\u044c&quot;;         break;       case '07':         $name = &quot;\u0438\u044e\u043b\u044c&quot;;         break;       case '08':         $name = &quot;\u0430\u0432\u0433\u0443\u0441\u0442&quot;;         break;       case '09':         $name = &quot;\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c&quot;;         break;       case '10':         $name = &quot;\u043e\u043a\u0442\u044f\u0431\u0440\u044c&quot;;         break;       case '11':         $name = &quot;\u043d\u043e\u044f\u0431\u0440\u044c&quot;;         break;       case '12':         $name = &quot;\u0434\u0435\u043a\u0430\u0431\u0440\u044c&quot;;         break;              default:         $name = &quot;&quot;;         break;     }     return $name;   } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u044f\u0446\u0430, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043d\u0435\u0432\u043d\u0438\u043a\u0430  <\/p>\n<pre><code class=\"php\">\/\/ \u0415\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u0441\u044f\u0446               if (isset($_GET[&quot;date&quot;])) {                 $cur_date = $_GET[&quot;date&quot;];                 $db = new SafeMySQL($set_bd);                 $data = $db-&gt;getAll(&quot;SELECT * FROM `notes` WHERE `date_cat` = ?s ORDER BY `id` DESC&quot;, $cur_date);                 foreach ($data as $key) {                   \/\/ \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442                   $xtea = new XTEA($_SESSION['key']);                   $text_decode = $xtea-&gt;Decrypt($key[&quot;text&quot;]);                   \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438                   echo '&lt;tr&gt;                     &lt;td class=&quot;date&quot;&gt;                       &lt;div class=&quot;date_m&quot;&gt;'.num2name($key[&quot;date_m&quot;]).'&lt;\/div&gt;                       &lt;div class=&quot;date_d&quot;&gt;'.$key[&quot;date_d&quot;].'&lt;\/div&gt;                       &lt;div class=&quot;date_t&quot;&gt;'.$key[&quot;date_t&quot;].'&lt;\/div&gt;                     &lt;\/td&gt;                     &lt;td class=&quot;note_text&quot; valign=&quot;top&quot;&gt;'.$text_decode.'&lt;\/td&gt;                   &lt;\/tr&gt;';                 }               }               \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u0435\u0441\u044f\u0446, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 $set_col \u0437\u0430\u043f\u0438\u0441\u0435\u0439               else {                 $db = new SafeMySQL($set_bd);                 $data = $db-&gt;getAll(&quot;SELECT * FROM `notes` ORDER BY `id` DESC LIMIT ?i&quot;, $set_col);                 foreach ($data as $key) {                   \/\/ \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442                   $xtea = new XTEA($_SESSION['key']);                   $text_decode = $xtea-&gt;Decrypt($key[&quot;text&quot;]);                   \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438                   echo '&lt;tr&gt;                     &lt;td class=&quot;date&quot;&gt;                       &lt;div class=&quot;date_m&quot;&gt;'.num2name($key[&quot;date_m&quot;]).'&lt;\/div&gt;                       &lt;div class=&quot;date_d&quot;&gt;'.$key[&quot;date_d&quot;].'&lt;\/div&gt;                       &lt;div class=&quot;date_t&quot;&gt;'.$key[&quot;date_t&quot;].'&lt;\/div&gt;                     &lt;\/td&gt;                     &lt;td class=&quot;note_text&quot; valign=&quot;top&quot;&gt;'.$text_decode.'&lt;\/td&gt;                   &lt;\/tr&gt;';                 }               }  <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/8ea\/ae9\/052\/8eaae90528e040d981252d25266f87fd.png\"\/><br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443  <\/p>\n<pre><code class=\"html\">&lt;form method=&quot;post&quot; action=&quot;&quot;&gt; &lt;textarea rows=&quot;10&quot; name=&quot;text&quot; placeholder=&quot;\u0422\u0435\u043a\u0441\u0442 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438&quot;&gt;&lt;\/textarea&gt; &lt;input type=&quot;submit&quot; value=&quot;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c&quot;&gt; &lt;\/form&gt; <\/code><\/pre>\n<p>  \u041a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c  <\/p>\n<pre><code class=\"php\">if (isset($_POST[&quot;text&quot;])) { \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 $text = nl2br($_POST[&quot;text&quot;]); \/\/ \u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 $xtea = new XTEA($_SESSION['key']); $text = $xtea-&gt;Encrypt($text);  $date_d = date(&quot;d&quot;); $date_m = date(&quot;m&quot;); $date_t = date(&quot;Y&quot;); $date_cat = date(&quot;n-Y&quot;); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 $db = new SafeMySQL($set_bd); $sql  = &quot;INSERT INTO `notes` (`text`, `date_d`, `date_m`, `date_t`, `date_cat`) VALUES (?s, ?s, ?s, ?s, ?s)&quot;; $db-&gt;query($sql, $text, $date_d, $date_m, $date_t, $date_cat); } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443 \u0441\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0434\u043b\u044f \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0443 \u043d\u0435\u0433\u043e \u043d\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php   \/\/ \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435   ini_set('error_reporting', E_ALL);   ini_set('display_errors', 1);   ini_set('display_startup_errors', 1);    include &quot;config.php&quot;;   include &quot;db.php&quot;;   include 'xtea.php';    header('Content-Type: text\/html; charset=utf-8');   session_start();    \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u043b\u044e\u0447\u0430   if (!isset($_SESSION['key'])) {     $keyw = '&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;key&quot; placeholder=&quot;\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448 \u043a\u043b\u044e\u0447&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&quot;&gt;&lt;\/form&gt;';   }   \/\/ \u0418\u043d\u0430\u0447\u0435, \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442   else {     $keyw = '&lt;button&gt;&lt;a class=&quot;nodec_link&quot; href=&quot;index.php?action=delkey&quot;&gt;\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043b\u044e\u0447&lt;\/a&gt;&lt;\/button&gt;';   }   \/\/ \u0415\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u0444\u043e\u0440\u043c\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430   if (isset($_POST[&quot;key&quot;])) {     $_SESSION['key'] = $_POST[&quot;key&quot;];     header(&quot;Location: index.php&quot;);     exit();   }   if ((isset($_GET['action'])) && ($_GET['action'] == 'delkey')) {     unset($_SESSION['key']);     header(&quot;Location: index.php&quot;);     exit();   }   \/\/ \u0435\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u0444\u043e\u0440\u043c\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438   if (isset($_POST[&quot;text&quot;])) {     $text = nl2br($_POST[&quot;text&quot;]);      $xtea = new XTEA($_SESSION['key']);     $text = $xtea-&gt;Encrypt($text);      $date_d = date(&quot;d&quot;);     $date_m = date(&quot;m&quot;);     $date_t = date(&quot;Y&quot;);     $date_cat = date(&quot;n-Y&quot;);      $db = new SafeMySQL($set_bd);     $sql  = &quot;INSERT INTO `notes` (`text`, `date_d`, `date_m`, `date_t`, `date_cat`) VALUES (?s, ?s, ?s, ?s, ?s)&quot;;     $db-&gt;query($sql, $text, $date_d, $date_m, $date_t, $date_cat);   }    \/\/ \u0424\u0443\u043d\u043a\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043d\u043e\u043c\u0435\u0440\u0430 \u043c\u0435\u0441\u044f\u0446\u0430 \u0432 \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435   function num2name($num) {     switch ($num) {       case '01':         $name = &quot;\u044f\u043d\u0432\u0430\u0440\u044c&quot;;         break;       case '02':         $name = &quot;\u0444\u0435\u0432\u0440\u0430\u043b\u044c&quot;;         break;       case '03':         $name = &quot;\u043c\u0430\u0440\u0442&quot;;         break;       case '04':         $name = &quot;\u0430\u043f\u0440\u0435\u043b\u044c&quot;;         break;       case '05':         $name = &quot;\u043c\u0430\u0439&quot;;         break;       case '06':         $name = &quot;\u0438\u044e\u043d\u044c&quot;;         break;       case '07':         $name = &quot;\u0438\u044e\u043b\u044c&quot;;         break;       case '08':         $name = &quot;\u0430\u0432\u0433\u0443\u0441\u0442&quot;;         break;       case '09':         $name = &quot;\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c&quot;;         break;       case '10':         $name = &quot;\u043e\u043a\u0442\u044f\u0431\u0440\u044c&quot;;         break;       case '11':         $name = &quot;\u043d\u043e\u044f\u0431\u0440\u044c&quot;;         break;       case '12':         $name = &quot;\u0434\u0435\u043a\u0430\u0431\u0440\u044c&quot;;         break;              default:         $name = &quot;&quot;;         break;     }     return $name;   } ?&gt; &lt;!DOCTYPE html&gt; &lt;html lang=&quot;ru&quot;&gt; &lt;head&gt;     &lt;meta charset=&quot;utf-8&quot;&gt;     &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;     &lt;link href='https:\/\/fonts.googleapis.com\/css?family=Open+Sans&subset=latin,cyrillic' rel='stylesheet' type='text\/css'&gt;     &lt;title&gt;&lt;?php echo $set_title; ?&gt;&lt;\/title&gt;     &lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt; &lt;\/head&gt; &lt;body&gt;     &lt;div class=&quot;main&quot;&gt;       &lt;table&gt;         &lt;tr&gt;             &lt;select onchange=&quot;location.href=this.options[this.selectedIndex].value;&quot;&gt;               &lt;option value=&quot;index.php&quot;&gt;\u0412\u044b\u0431\u043e\u0440 \u043c\u0435\u0441\u044f\u0446\u0430 \u0438 \u0433\u043e\u0434\u0430&lt;\/option&gt;               &lt;option value=&quot;index.php&quot;&gt;\u041f\u043e\u0441\u043b\u0435\u0434\u0438\u043d\u0435 &lt;?php echo $set_col; ?&gt; \u0437\u0430\u043f\u0438\u0441\u0435\u0439&lt;\/option&gt;               &lt;?php                 $db = new SafeMySQL($set_bd);                 $option = $db-&gt;getAll(&quot;SELECT DISTINCT `date_cat` FROM `notes`&quot;);                 foreach ($option as $value) {                   $desc_opt = explode(&quot;-&quot;, $value['date_cat']);                   echo '&lt;option value=&quot;index.php?date='.$value['date_cat'].'&quot;&gt;'.num2name($desc_opt[0]).' '.$desc_opt[1].'&lt;\/option&gt;';                 }               ?&gt;             &lt;\/select&gt;         &lt;\/tr&gt;         &lt;tr&gt;           &lt;?php echo $keyw; ?&gt;         &lt;\/tr&gt;       &lt;\/table&gt;       &lt;h1&gt;&lt;?php echo $set_title; ?&gt;&lt;\/h1&gt;       &lt;div class=&quot;addform&quot;&gt;         &lt;form method=&quot;post&quot; action=&quot;&quot;&gt;           &lt;textarea rows=&quot;10&quot; name=&quot;text&quot; placeholder=&quot;\u0422\u0435\u043a\u0441\u0442 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438&quot;&gt;&lt;\/textarea&gt;           &lt;input type=&quot;submit&quot; value=&quot;\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c&quot;&gt;         &lt;\/form&gt;       &lt;\/div&gt;       &lt;div class=&quot;notes&quot;&gt;         &lt;table class=&quot;table&quot;&gt;           &lt;tbody&gt;             &lt;?php                \/\/ \u0415\u0441\u043b\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u0441\u044f\u0446               if (isset($_GET[&quot;date&quot;])) {                 $cur_date = $_GET[&quot;date&quot;];                 $db = new SafeMySQL($set_bd);                 $data = $db-&gt;getAll(&quot;SELECT * FROM `notes` WHERE `date_cat` = ?s ORDER BY `id` DESC&quot;, $cur_date);                 foreach ($data as $key) {                   \/\/ \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442                   $xtea = new XTEA($_SESSION['key']);                   $text_decode = $xtea-&gt;Decrypt($key[&quot;text&quot;]);                   \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438                   echo '&lt;tr&gt;                     &lt;td class=&quot;date&quot;&gt;                       &lt;div class=&quot;date_m&quot;&gt;'.num2name($key[&quot;date_m&quot;]).'&lt;\/div&gt;                       &lt;div class=&quot;date_d&quot;&gt;'.$key[&quot;date_d&quot;].'&lt;\/div&gt;                       &lt;div class=&quot;date_t&quot;&gt;'.$key[&quot;date_t&quot;].'&lt;\/div&gt;                     &lt;\/td&gt;                     &lt;td class=&quot;note_text&quot; valign=&quot;top&quot;&gt;'.$text_decode.'&lt;\/td&gt;                   &lt;\/tr&gt;';                 }               }               \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u0435\u0441\u044f\u0446, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 $set_col \u0437\u0430\u043f\u0438\u0441\u0435\u0439               else {                 $db = new SafeMySQL($set_bd);                 $data = $db-&gt;getAll(&quot;SELECT * FROM `notes` ORDER BY `id` DESC LIMIT ?i&quot;, $set_col);                 foreach ($data as $key) {                   \/\/ \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442                   $xtea = new XTEA($_SESSION['key']);                   $text_decode = $xtea-&gt;Decrypt($key[&quot;text&quot;]);                   \/\/ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438                   echo '&lt;tr&gt;                     &lt;td class=&quot;date&quot;&gt;                       &lt;div class=&quot;date_m&quot;&gt;'.num2name($key[&quot;date_m&quot;]).'&lt;\/div&gt;                       &lt;div class=&quot;date_d&quot;&gt;'.$key[&quot;date_d&quot;].'&lt;\/div&gt;                       &lt;div class=&quot;date_t&quot;&gt;'.$key[&quot;date_t&quot;].'&lt;\/div&gt;                     &lt;\/td&gt;                     &lt;td class=&quot;note_text&quot; valign=&quot;top&quot;&gt;'.$text_decode.'&lt;\/td&gt;                   &lt;\/tr&gt;';                 }               }              ?&gt;           &lt;\/tbody&gt;         &lt;\/table&gt;       &lt;\/div&gt;      &lt;\/div&gt;    &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u0421\u0441\u044b\u043b\u043a\u0438<\/b><br \/>  <a href=\"https:\/\/bitbucket.org\/pingvi\/personal_diary\/src\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a><br \/>  <a href=\"https:\/\/github.com\/colshrapnel\/safemysql\/blob\/master\/safemysql.class.php\">SafeMySQL<\/a><br \/>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/XTEA\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c XTEA<\/a>       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/273587\/\"> http:\/\/habrahabr.ru\/post\/273587\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a!<\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432 \u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u043d\u0435\u0432\u043d\u0438\u043a\u0430, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0435\u043c \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c <s>\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434<\/s> \u043b\u0438\u0447\u043d\u044b\u0439 \u0434\u043d\u0435\u0432\u043d\u0438\u043a (\u0437\u0430\u043f\u0438\u0441\u043d\u0443\u044e \u043a\u043d\u0438\u0436\u043a\u0443) \u043d\u0430 php \u0438 mysql \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 php-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u043b\u044e\u0434\u0438 \u044d\u0442\u043e \u0432\u0441\u0451 \u0437\u043d\u0430\u044e\u0442 \u0438 \u0441\u0434\u0435\u043b\u0430\u044e\u0442 \u0432\u0441\u0451 \u044d\u0442\u043e \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u043c\u0435\u043d\u044f.<\/p>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0438 \u2014 \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0430 \u043a\u043b\u044e\u0447 \u0437\u043d\u0430\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0437\u043b\u043e\u0443\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u0438\u043a \u0443\u043a\u0440\u0430\u0434\u0451\u0442 \u0432\u0430\u0448\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u044d\u0442\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0447\u0442\u043e \u043e\u043d \u0443\u0432\u0438\u0434\u0438\u0442:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f60\/12b\/7e6\/f6012b7e613e4fb09a8ac089bbfd4bd3.png\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-270776","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/270776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270776"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/270776\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}