<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if (is_file ("../../lang/".$lang.".php")) include "../../lang/".$lang.".php";
     else include "../../lang/ru.php";

  $title=$titlepage=$TEXT['global-news'];

  require_once "../config.php";
  require_once "../util/top_news.php";

  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  if(!isset($title)) $title = $TEXT['new-title'];
  if(!isset($button)) $button = $TEXT['btn_add'];
  if(!isset($action)) $action = "edit.php";

  if(empty($_POST['header'])) puterror2($TEXT['error-new1']);
  if(strlen($_POST['header'])>300) puterror2($TEXT['error-new2']);
  if(empty($_POST['message'])) puterror2($TEXT['error-new4']);
  if(strlen($_POST['message'])>60000) puterror2($TEXT['error-new5']);
  if(empty($_POST['position'])) puterror2($TEXT['error-new7']);
  if(strlen($_POST['position'])>11) puterror2($TEXT['error-new8']);
  if(strlen($_POST['description'])>300) puterror2($TEXT['error-new10']);

  $new = $_POST['message'];

  $_POST['message'] = str_replace(":smile:","<img alt='картинка' src='../img/smile.png' align=middle border=0 />",$_POST['message']);
  $_POST['message'] = str_replace(":tongue:","<img alt='картинка' src='../img/tongue.png' align=middle border=0 />",$_POST['message']);
  $_POST['message'] = str_replace(":wink:","<img alt='картинка' src='../img/wink.png' align=middle border=0 />",$_POST['message']);
  $_POST['message'] = str_replace(":wassat:","<img alt='картинка' src='../img/wassat.png' align=middle border=0 />",$_POST['message']);
  $_POST['message'] = str_replace(":sad:","<img alt='картинка' src='../img/sad.png' align=middle border=0 />",$_POST['message']);
  $_POST['message'] = str_replace(":crying:","<img alt='картинка' src='../img/crying.png' align=middle border=0 />",$_POST['message']);
  $_POST['message'] = str_replace(":angry:","<img alt='картинка' src='../img/angry.png' align=middle border=0 />",$_POST['message']);

  $header = $_POST['header'];
  $position = $_POST['position'];
  $description = $_POST['description'];
  $org_id = $_POST['org_id'];
  $news_id = $_POST['news_id'];
  $old_org_id = $_POST['old_org_id'];
  $old_picture = $_POST['old_picture'];
  $old_picture_big = $_POST['old_picture_big'];
  $url = $_POST['url'];
  $url_text = $_POST['url_text'];

  if($old_picture == "") $newsphoto = "<img class='photo' src='../img/emptyphoto.png' alt='".$TEXT['no-pic']."' width='133' height='99' align=left />";
    else $newsphoto = "<a href='../".$old_picture_big."' target=_blank title='".$TEXT['tbl-pic-tit']."' ><img src='../".$old_picture."' alt='".$TEXT['no-pic']."' align=left /></a>";
 ?>
 <form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
 <table class="table" border="0" cellpadding="5" cellspacing="1" width="85%">
 <?php
 echo "<tr><td class='news2'>".$_POST['header']."</td></tr>";
 echo "<tr><td class='newsbody'>".$newsphoto."&nbsp; ".nl2br($_POST['message'])."<br />&nbsp;<span class='useraddedit'>".$TEXT['no-link']."</span></td></tr>";
?>
</table>
<table class="table" border="0" cellpadding="5" cellspacing="1" width="85%">
<tr><td class="useraddedit" width="15%"><?php echo $TEXT['pic']; ?></td><td class="useraddedit"><input type=file name=image ><input type=checkbox name=clear_picture> <?php echo $TEXT['tbl-delete']; ?></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['photo_obr']; ?></td><td>
    <select name="photo_obr">
  <option value='1' selected><?php echo $TEXT['photo_no']; ?>
  <option value='2' ><?php echo $TEXT['photo_rec_l']; ?>
  <option value='3' ><?php echo $TEXT['photo_rec_v']; ?>
  <option value='4' ><?php echo $TEXT['photo_rec_l_t']; ?>
  <option value='5' ><?php echo $TEXT['photo_rec_v_t']; ?>
    </select>
   </td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['tbl-pic2']; ?></td><td class="useraddedit"><input class="inputmandatory" type=file name=image2 ></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['link']; ?></td><td class="useraddedit"><input size=50 maxlength=250 type=text name=url value='<?php echo $url; ?>'></td></tr>
<tr><td class="useraddedit"><?php echo $TEXT['link-descrip']; ?></td><td class="useraddedit"><input size=50 maxlength=100 type=text name=url_text value='<?php echo $url_text; ?>'></td></tr>
<tr><td width=15%></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=header value='<?php echo $header; ?>'>
<input type=hidden name=new value='<?php echo $new; ?>'>
<input type=hidden name=position value='<?php echo $position; ?>'>
<input type=hidden name=description value='<?php echo $description; ?>'>
<input type=hidden name=org_id value='<?php echo $org_id; ?>'>
<input type=hidden name=old_org_id value='<?php echo $old_org_id; ?>'>
<input type=hidden name=visible value='<?php echo $visible; ?>'>
<input type=hidden name=news_id value='<?php echo $news_id; ?>'>
<input type=hidden name=old_picture value='<?php echo $old_picture; ?>'>
<input type=hidden name=old_picture_big value='<?php echo $old_picture_big; ?>'>
</td></tr>
</table>
</form>
<?php
  require_once "../../utils/bottom.php";
?>