Просмотр файла libs/new.stat.php

Размер файла: 2.53Kb
  1. <?
  2.  
  3.  
  4. define('SHCMS', true);
  5. include_once'../system/inc/basic_settings.php';
  6. if($_GET['id']){$id=$_GET['id'];}
  7. registrat();
  8. $lib = mysql_fetch_array(mysql_query("SELECT * FROM `libs` WHERE `id` = '$id'"));
  9. $shcmsengine['title'] = 'Библиотека - '.$lib['name'].' - Добавить статью';
  10. include_once'../template/head.php';
  11.  
  12. if($_POST['submit']){$submit = $_POST['submit'];}
  13. if(isset($submit))
  14. {
  15. if($_POST['name']){$name = $_POST['name'];}
  16. if($_POST['text']){$text = $_POST['text'];}
  17.  
  18.  
  19. if(empty($name))
  20. {echo '<div class="errors">Введите названия статьи</div>';
  21. header("Refresh: 1; url=new.stat.php?id=$id");
  22. include_once'../template/foot.php';
  23. exit;}
  24.  
  25. $lib_prov = mysql_query("SELECT * FROM `libs_stat` WHERE `name`='" . mysql_real_escape_string($name) . "';");
  26. if (mysql_fetch_array($lib_prov) != 0) {
  27. echo '<div class="errors">Статья с такой названией уже есть в библиотеке</div>';
  28. header("Refresh: 1; url=?id=".$id."");
  29. include_once'../template/foot.php';
  30. exit();
  31. }
  32.  
  33. if(strlen($name) <1 || strlen($name) > 100)
  34. {echo '<div class="errors">Название должно быть не больше 60 символов</div>';
  35. header("Refresh: 1; url=new.stat.php?id=$id");
  36. include_once'../template/foot.php';
  37. exit;}
  38. if(empty($text))
  39. {echo '<div class="errors">Введите текст статьи</div>';
  40. header("Refresh: 1; url=new.stat.php?id=$id");
  41. include_once'../template/foot.php';
  42. exit;}
  43.  
  44.  
  45.  
  46. $libs = mysql_query("INSERT INTO `libs_stat` (`dir`,`name`,`text`,`time`,`user_id`) VALUES ('$id','$name','".my_esc($text)."','".time()."','$user_id')");
  47. if($libs == true){echo '<div class="actshcms">Статья успешно добавлена</div>';
  48. header("Refresh: 1; url=/libs/list.php?id=$id");
  49. include_once'../template/foot.php';
  50. exit;}
  51. else
  52. {errors('Возникла ошибка при добавлении статьи');
  53. header("Refresh: 1; url=new.stat.php?id=$id");
  54. include_once'../template/foot.php';
  55. exit;}
  56.  
  57. }
  58.  
  59.  
  60.  
  61. echo '<form action="?id='.$id.'" method="post" name="form">';
  62. echo '<strong>Названия статьи:</strong><br/><input type="text" name="name"><br/>';
  63. echo '<strong>Текст статьи:</strong><br/><textarea id="text" name="text"></textarea><br/>';
  64. echo '<input type="submit" name="submit" value="Добавить"> ';
  65. echo '<input type="submit" name="refresh" value="Обновить">';
  66. echo '</form>';
  67.  
  68.  
  69.  
  70.  
  71. include_once'../template/foot.php';
  72. ?>