PageRenderTime 36ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/dpanel/adt.new.banner.php

https://bitbucket.org/DESURE/dcms
PHP | 87 lines | 71 code | 16 blank | 0 comment | 12 complexity | 392ecd120e9d87bc57a1a364d17876a4 MD5 | raw file
  1. <?php
  2. include_once '../sys/inc/start.php';
  3. dpanel::check_access();
  4. $advertisement = new adt();
  5. $doc = new document(5);
  6. $doc->title = __('????? ??????');
  7. if (!isset($_GET['id'])) {
  8. header('Refresh: 1; url=adt.php');
  9. $doc->ret(__('??????? ? ???????'), 'adt.php');
  10. $doc->ret(__('???????'), '/dpanel/');
  11. $doc->err(__('?????? ?????? ???????'));
  12. exit;
  13. }
  14. $id_space = (string) $_GET['id'];
  15. if (!$name = $advertisement->getNameById($id_space)) {
  16. header('Refresh: 1; url=?');
  17. $doc->err(__('???????? ??????? ???????????'));
  18. exit;
  19. }
  20. if (isset($_POST['create'])) {
  21. $code_main = text::input_text(@$_POST['code_main']);
  22. $code_other = text::input_text(@$_POST['code_other']);
  23. $pattern = '#<a +href\="(.+?)"><img +src\="(.+?)" +alt\="(.+?)" ?/></a>#ui';
  24. if (empty($_POST['captcha']) || empty($_POST['captcha_session']) || !captcha::check($_POST['captcha'], $_POST['captcha_session'])) {
  25. $design->err(__('??????????? ????? ??????? ???????'));
  26. } else {
  27. if (preg_match($pattern, $code_main, $main)) {
  28. $dcms->log('???????', '????????? ??????? [url=/dpanel/adt.php?id=' . $id_space . ']' . $main[1] . '[/url]');
  29. if ($code_main == $code_other) {
  30. mysql_query("INSERT INTO `advertising` (`space`, `url_link`, `name`, `url_img`, `page_main`, `page_other`, `time_create`, `time_start`, `time_end`, `bold`)
  31. VALUES ('" . my_esc($id_space) . "', '" . my_esc($main[1]) . "', '" . my_esc($main[3]) . "', '" . my_esc($main[2]) . "', '1', '1', '" . TIME . "', '0', '0', '0')");
  32. header('Refresh: 1; url=adt.settings.php?id=' . $id_space);
  33. $doc->msg(__('?????? ??????? ??????????'));
  34. $doc->ret(__('?????????'), "adt.php?id=$id_space");
  35. $doc->ret(__('????????? ???????'), 'adt.php');
  36. $doc->ret(__('???????'), '/dpanel/');
  37. exit;
  38. } else {
  39. mysql_query("INSERT INTO `advertising` (`space`, `url_link`, `name`, `url_img`, `page_main`, `page_other`, `time_create`, `time_start`, `time_end`, `bold`)
  40. VALUES ('" . my_esc($id_space) . "', '" . my_esc($main[1]) . "', '" . my_esc($main[3]) . "', '" . my_esc($main[2]) . "', '1', '0', '" . TIME . "', '0', '0', '0')");
  41. $doc->msg(__('?????? ??? ??????? ???????? ??????? ??????????'));
  42. if (preg_match($pattern, $code_other, $other)) {
  43. mysql_query("INSERT INTO `advertising` (`space`, `url_link`, `name`, `url_img`, `page_main`, `page_other`, `time_create`, `time_start`, `time_end`, `bold`)
  44. VALUES ('" . my_esc($id_space) . "', '" . my_esc($other[1]) . "', '" . my_esc($other[3]) . "', '" . my_esc($other[2]) . "', '0', '1', '" . TIME . "', '0', '0', '0')");
  45. $doc->msg(__('?????? ??? ????????? ??????? ??????? ??????????'));
  46. }
  47. header('Refresh: 1; url=adt.php?id=' . $id_space);
  48. $doc->ret(__('?????????'), "adt.php?id=$id_space");
  49. $doc->ret(__('????????? ???????'), 'adt.php');
  50. $doc->ret(__('???????'), '/dpanel/');
  51. exit;
  52. }
  53. }else
  54. $doc->err(__('?????????? ????????? ???'));
  55. }
  56. }
  57. $form = new design();
  58. $form->assign('method', 'post');
  59. $form->assign('action', "?id=$id_space&amp;" . passgen());
  60. $elements = array();
  61. $elements[] = array('type' => 'textarea', 'title' => __('HTML - ??? (??? ???????)'), 'br' => 1, 'info' => array('name' => 'code_main'));
  62. $elements[] = array('type' => 'textarea', 'title' => __('HTML - ??? (??? ?????????)'), 'br' => 1, 'info' => array('name' => 'code_other'));
  63. $elements[] = array('type' => 'captcha', 'session' => captcha::gen(), 'br' => 1);
  64. $elements[] = array('type' => 'text', 'value' => '* ' . __('???????????? ???? ????????? waplog.net ? ????????'), 'br' => 1);
  65. $elements[] = array('type' => 'submit', 'br' => 0, 'info' => array('name' => 'create', 'value' => __('???????'))); // ??????
  66. $form->assign('el', $elements);
  67. $form->display('input.form.tpl');
  68. $doc->ret(__('?????????'), "adt.php?id=$id_space");
  69. $doc->ret(__('????????? ???????'), 'adt.php');
  70. $doc->ret(__('???????'), '/dpanel/');
  71. ?>