<?

  include '../FCKeditor/fckeditor.php';
  include_once '../../config.inc.php';
  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

  if (!($result_proper = mysql_query ('select * from properties')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  $proper = mysql_fetch_array ($result_proper);
  include '../lang/' . $proper['admin_language'];
  include '../../lang/' . $proper['language'];
  echo '
<HTML><BODY STYLE="color: Navy;"><LINK HREF="../style.css" REL="stylesheet" TYPE="text/css"><TABLE WIDTH="686" BORDER=0 CELLSPACING=0 CELLPADDING=1><TR><TD style="background-color:#505090;"><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=5 BGCOLOR="#EFEFF8">
<TR><TD VALIGN=top BGCOLOR="#BFBFDF" STYLE="border-bottom: 1px solid #505090;"><FONT COLOR="navy"><B>';
  echo $admin_Add_New_Article;
  echo '</B></FONT></TD></TR><TR><TD VALIGN=top>

';
  if ($_POST['add_article'])
  {
    if (!$_POST['status'])
    {
      $_POST['status'] = 0;
    }

    $post_tim = mktime ($_POST['post_hour'], $_POST['post_minute'], $_POST['post_sec'], $_POST['post_month'] + 1, $_POST['post_day'], $_POST['post_year']);
    $SQL = '' . 'INSERT INTO articles VALUES(\'\',
	\'' . $_POST['type'] . '\',
	\'' . $_POST['category'] . '\',
	\'' . $post_tim . '\',
	\'' . $_POST['status'] . '\',
	\'' . trim ($_POST['title']) . '\',
	\'' . trim ($_POST['description']) . '\',
	\'' . $_POST['FCKeditor1'] . ('' . '\',
	\'' . $_COOKIE['autorized'] . '\'
	)');
    if (!(mysql_query ($SQL)))
    {
      exit ('Can\'t PUBLISH Article!');
      ;
    }

    if ($_FILES['image']['name'])
    {
      if (copy ($_FILES['image']['tmp_name'], $documentroot . ('' . '/upload/images/' . $post_tim . '.') . substr ($_FILES['image']['type'], 6)))
      {
        unlink ($_FILES['image']['tmp_name']);
      }
    }

    if ($_FILES['thumbnail']['name'])
    {
      if (copy ($_FILES['thumbnail']['tmp_name'], $documentroot . ('' . '/upload/thumbnails/' . $post_tim . '.') . substr ($_FILES['thumbnail']['type'], 6)))
      {
        unlink ($_FILES['thumbnail']['tmp_name']);
      }
    }

    if ($_FILES['multimedia']['name'])
    {
      if (strstr ($_FILES['multimedia']['type'], 'wmv'))
      {
        $extension = 'wmv';
      }
      else
      {
        $extension = substr ($_FILES['multimedia']['type'], 6);
      }

      if (copy ($_FILES['multimedia']['tmp_name'], $documentroot . ('' . '/upload/multimedia/' . $post_tim . '.') . $extension))
      {
        unlink ($_FILES['multimedia']['tmp_name']);
      }
    }
  }

  echo '

<FORM ACTION="add.php" METHOD=post ENCTYPE="multipart/form-data">

';
  echo $admin_Article_type;
  echo '<INPUT TYPE=radio NAME="type" VALUE="0" onClick="this.form.category.disabled=false; this.form.thumbnail.disabled=false;" checked>';
  echo $admin_Typical;
  echo '&nbsp;|
<INPUT TYPE=radio NAME="type" VALUE="1" onClick="this.form.category.disabled=true; this.form.thumbnail.disabled=true;">';
  echo $admin_Breaking_News;
  echo '&nbsp;|
<INPUT TYPE=radio NAME="type" VALUE="2"onClick="this.form.category.disabled=false; this.form.thumbnail.disabled=false;">';
  echo $admin_Headline;
  echo '&nbsp;|
<INPUT TYPE=radio NAME="type" VALUE="3"onClick="this.form.category.disabled=true;">';
  echo $admin_Interview;
  echo '
<BR><BR>

';
  echo $admin_Category;
  echo '<S';
  echo 'ELECT NAME="category">
';
  if (!($result1 = mysql_query ('SELECT * FROM categories')))
  {
    exit ('Query failed4');
    ;
  }

  $i = 0;
  while ($row1 = mysql_fetch_array ($result1))
  {
    $TMP1[$i++] = $row1['id'];
  }

  if (!($result = mysql_query ('' . 'SELECT * FROM users WHERE md5(md5(password))=\'' . $_COOKIE['catselect'] . '\'')))
  {
    exit ('Query failed4');
    ;
  }

  $row = mysql_fetch_array ($result);
  $TMP = split ('
', $row['allowed']);
  $match = array_intersect ($TMP, $TMP1);
  for ($i = 0; $i < sizeof ($match); ++$i)
  {
    if ($match[$i] != '')
    {
      if (!($result = mysql_query ('' . 'SELECT * FROM categories WHERE id=\'' . $match[$i] . '\'')))
      {
        exit ('Query failed4');
        ;
      }

      $row = mysql_fetch_array ($result);
    }

    if ($row['name'] != '')
    {
      echo '<option value="';
      echo $row['name'];
      echo '">';
      echo $row['name'];
      echo '</option>';
      if (!($result11 = mysql_query ('' . 'SELECT * FROM sub_categories WHERE parent=\'' . $match[$i] . '\'')))
      {
        exit ('Query failed');
        ;
      }

      $row11 = mysql_fetch_array ($result11);
      if ($row11['name'] != '')
      {
        echo $cat11 = split ('
', $row11[1]);
        for ($j = 0; $j < sizeof ($cat11); ++$j)
        {
          echo '<option value="';
          echo $row['name'] . '~' . $cat11[$j];
          echo '">&nbsp;&middot;&nbsp;';
          echo $cat11[$j];
          echo '</option>';
        }

        continue;
      }

      continue;
    }
  }

  echo '</select>		

<BR><BR>

';
  echo $admin_Post_date;
  echo '<S';
  echo 'ELECT NAME="post_day">';
  for ($i = 1; $i < 32; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('j', $curtime[0]))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT>
';
  echo '<S';
  echo 'ELECT NAME="post_month">';
  for ($i = 0; $i < 12; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('n', $curtime[0]) - 1)
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $month[$i];
    echo '</OPTION>';
  }

  echo '</SELECT>
';
  echo '<S';
  echo 'ELECT NAME="post_year">';
  for ($i = 1980; $i <= date ('Y', $curtime[0]); ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('Y', $curtime[0]))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT>
';
  echo $admin_time;
  echo '<S';
  echo 'ELECT NAME="post_hour">';
  for ($i = 0; $i <= 23; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('G', $curtime[0]))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT>&nbsp;:
';
  echo '<S';
  echo 'ELECT NAME="post_minute">';
  for ($i = 0; $i <= 59; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('i', $curtime[0]))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT> :
';
  echo '<S';
  echo 'ELECT NAME="post_sec">';
  for ($i = 0; $i <= 59; ++$i)
  {
    echo '<OPTION VALUE="';
    echo $i;
    echo '" ';
    if ($i == date ('s', $curtime[0]))
    {
      echo 'SELECTED';
    }

    echo '>';
    echo $i;
    echo '</OPTION>';
  }

  echo '</SELECT>
<BR><BR>

';
  if (($_COOKIE['root'] OR $_COOKIE['editor']))
  {
    echo $admin_Status;
    echo '<S';
    echo 'ELECT NAME="status">
	<OPTION VALUE="0">';
    echo $admin_Pending;
    echo '</OPTION>
	<OPTION VALUE="1" SELECTED>';
    echo $admin_Visible;
    echo '</OPTION>
	<OPTION VALUE="2">';
    echo $admin_Hidden;
    echo '</OPTION>
</SELECT>
<BR><BR>
';
  }

  echo '
<DIV ALIGN="center">';
  echo $admin_Article_Title;
  echo '</DIV><TEXTAREA NAME=title COLS="130" ROWS=3></TEXTAREA>

<BR>

<DIV ALIGN="center">';
  echo $admin_Short_Description;
  echo '</DIV><TEXTAREA NAME=description COLS=130 ROWS=6></TEXTAREA>

<BR>

<DIV ALIGN="center">';
  echo $admin_Body;
  echo '</DIV>

';
  $oFCKeditor = new FCKeditor ('FCKeditor1');
  $oFCKeditor->BasePath = $sBasePath;
  $oFCKeditor->Width = '110%';
  $oFCKeditor->Height = '500';
  $oFCKeditor->Config['DefaultLanguage'] = 'en';
  $oFCKeditor->Create ();
  echo '
<BR>

';
  echo $admin_Image;
  echo '<BR><INPUT TYPE=file NAME="image" SIZE=70 ACCEPT="image/jpeg,image/gif"><BR><BR>
';
  echo $admin_Thumbnail;
  echo '<BR><INPUT TYPE=file NAME="thumbnail" SIZE=70 ACCEPT="image/jpeg,image/gif"><BR><BR>
';
  echo $admin_Audio_Video_file;
  echo '<BR><INPUT TYPE=file NAME="multimedia" SIZE=70><BR><BR>

<INPUT TYPE=submit NAME="add_article" VALUE="';
  echo $admin_Save_Article;
  echo '">

</FORM>
</TD></TR></TABLE></TD></TR></TABLE></BODY></HTML>';
?>
