<?
$page = "add_entry.php";
include "manager_header.php";

if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "main"; }




if(isset($_GET['task']) AND $_GET['task'] == "addsmilie") {
$server_array = explode("/", $_SERVER['PHP_SELF']);
$server_info = implode("/", $server_array);
$prefix = str_replace("manager/add_entry.php", "images/smilies", "http://".$_SERVER['HTTP_HOST'].$server_info);
echo "
<html>
<head>
<title>Insert Smilie</title>
<style type='text/css'>
body { margin: 15px; }
</style>
<script language='JavaScript' type='text/javascript' src='../include/richtext.js'></script>
<script language='JavaScript'>
<!--
function addtheSmilie(imageURL) {
self.parent.addSmilie(imageURL, 'contents');
window.close();
}
// -->
</script>
</head>
<body onload='window.focus()'>
<table cellpadding='0' cellspacing='0' width='100%' height='100%'>
<tr>
<td align='center' valign='center'>
";


// READ FROM SMILIES DIRECTORY
$dirname="../images/smilies";
$dh = @opendir($dirname) or die("Error: Failed to open smilies directory.");

$filelist = array();
$c = 0;
while(!(($file = @readdir($dh)) === false)) {
if(!is_dir("$dirname/$file")) {
if(eregi("gif|jpeg|pjpeg|png", $file, $array)) {
$filelist[$c] = $file;
$c++;
}}}
closedir($dh);

sort($filelist);
$total = count($filelist);
$c = 0;
while($c < $total) {
echo "
<a href='#' onClick=\"addtheSmilie('$prefix/$filelist[$c]')\"><img src='../images/smilies/$filelist[$c]' border='0' style='margin: 5px;'></a>";
$c++;
}




echo "
</td></tr></table>
</body>
</html>
";
exit();
}







if($task == "doadd") {
$title = str_replace("<", "&lt;", str_replace(">", "&gt;", str_replace("'", "&#39;", $_POST['title'])));
$contents = str_replace("'", "&#39;", $_POST['contents']);
$tb_to_ping = $_POST['tb_to_ping'];
$tb_pinged = "";
$submit = stripslashes($_POST['submit']);
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];
$hour = $_POST['hour'];
$minute = $_POST['minute'];
$ampm = $_POST['ampm'];
$comments = $_POST['comments'];
$trackbacks = $_POST['trackbacks'];
$podcast = $_POST['podcast'];
$privacy = $_POST['privacy'];
$ec_id = $_POST['ec_id'];
$send_mail = $_POST['send_mail'];

// CONVERT DATE INTO UNIX TIMESTAMP
$date = strtotime("$month/$day/$year $hour:$minute:00 $ampm");
$date = untimezone($date);
$date = duplicatetime($date, 0);

// CENSOR BAD WORDS
$bad_words = explode(",", trim($admin_info[banned_badwords]));
$bad_words_replace = explode(",", trim($admin_info[banned_badwords_replace]));
$contents = str_replace($bad_words, $bad_words_replace, $contents);
$title = str_replace($bad_words, $bad_words_replace, $title);

// TAKE CARE OF PODCASTING
$remove_podcast = "yes";
if($owner_group_info[allow_podcast] == "1" & $podcast != "") {
 $add_to_contents = str_replace("'", "&#39;", "<p class=\"podcast\"><a href=\"$podcast\">$add_entry37</a> (<a href=\"".url("podcast", "$weblog_info[weblog]")."\">$add_entry38</a>)</p>");
 $ext = strtolower(str_replace(".", "", strtolower(strrchr($podcast, "."))));
 $extensions = explode(",", strtolower($group_info[podcast_extensions]));
 if(in_array($ext, $extensions)) {
  if($headers = get_file_headers($podcast)) {
   $podcast_size = $headers['content-length'];
   $podcast_type = $headers['content-type'];
   $first_mime = substr($podcast_type, 0, strpos($podcast_type, "/"));
   if($first_mime == "audio" | $first_mime == "video") { $remove_podcast = "no"; }
  }
 }
}

if($remove_podcast == "yes") {
 $podcast = "";
 $podcast_size = "";
 $podcast_type = "";
 $add_to_contents = "";
}

$contents = $add_to_contents.$contents;


// INSERT NEW ENTRY AS EITHER LIVE OR DRAFT
if(htmlentities($submit, ENT_QUOTES) == htmlentities(html_entity_decode($add_entry20, ENT_QUOTES), ENT_QUOTES)) { $draft = "1"; } else { $draft = "0"; }

mysql_query("INSERT INTO bhost_entries (w_id, author_u_id, ec_id, title, contents, draft, privacy, date, comments, trackbacks, podcast, podcast_size, podcast_type) VALUES ('$weblog_info[w_id]', '$user_info[u_id]', '$ec_id', '$title', '$contents', '$draft', '$privacy', '$date', '$comments', '$trackbacks', '$podcast', '$podcast_size', '$podcast_type')") or die(mysql_error());
$entry = mysql_fetch_assoc(mysql_query("SELECT e_id, title, contents FROM bhost_entries WHERE w_id='$weblog_info[w_id]' AND author_u_id='$user_info[u_id]' AND ec_id='$ec_id' AND title='$title' AND contents='$contents' AND date='$date'"));



$trackback_result = "";
include "../include/trackback_cls.php";
$trackback = new Trackback("$weblog_info[title]", "$user_info[display_name]", "UTF-8");
$tb_full_array = Array();
$detected_urls = 0;
if($tb_array = $trackback->auto_discovery($entry[contents])) {
 foreach($tb_array as $tb_key => $tb_url) {
  $tb_full_array[$detected_urls] = $tb_url;
  $detected_urls = $detected_urls + 1;
 }
}

if((str_replace(" ", "", $tb_to_ping) != "" | $detected_urls != 0) && $owner_group_info[allow_trackback] != 0) {
  // SEND TRACKBACKS IF NOT A DRAFT
  if($draft == "0") {
    $trackback_result = "$add_entry32<br>";
    $tb_to_ping_urls = explode(" ", trim($tb_to_ping));
    if($weblog_info[detect_trackbacks] == "1") {
     $tb_to_ping_urls = array_unique(array_merge($tb_to_ping_urls, $tb_full_array));
    }
    $tb_pinged = "";
    $tb_to_ping = "";
    $excerpt = substr($entry[contents], 0, 252)."...";
    if($entry[title] == "") { $title = "$add_entry33"; } else { $title = $entry[title]; }
    for($tb=0;$tb<count($tb_to_ping_urls);$tb++) {
      if(str_replace(" ", "", $tb_to_ping_urls[$tb]) != "") {

        $response = $trackback->ping("$tb_to_ping_urls[$tb]", url("entry", "$weblog_info[weblog]", "", "$entry[e_id]"), "$title", "$excerpt");
        if($response == "1") {
          $trackback_result .= "<i>$tb_to_ping_urls[$tb]</i> - $add_entry27<br>";
        } elseif($response == "2") {
          $trackback_result .= "<i>$tb_to_ping_urls[$tb]</i> - $add_entry28<br>";
          $tb_pinged .= "$tb_to_ping_urls[$tb] ";
        } else {
          $trackback_result .= "<i>$tb_to_ping_urls[$tb]</i> - $add_entry29<br>";
        }
      }
    }  
    $tb_pinged = trim($tb_pinged);
  } else {
    $tb_to_ping = $tb_to_ping;
    $tb_pinged = "";
  }

  // ENTER TRACKBACK URLs PINGED
  mysql_query("UPDATE bhost_entries SET tb_to_ping='$tb_to_ping', tb_pinged='$tb_pinged' WHERE e_id='$entry[e_id]' AND w_id='$weblog_info[w_id]'");
}




// INCREMENT NUM_ENTRIES IN BHOST_USERS AND BHOST_WEBLOGS
mysql_query("UPDATE bhost_users SET num_entries=num_entries+1 WHERE u_id='$user_info[u_id]'");
mysql_query("UPDATE bhost_weblogs SET num_entries=num_entries+1 WHERE w_id='$weblog_info[w_id]'");

if($send_mail == "1" & $draft == "0") {
 if(str_replace(" ", "", $title) == "") { $title = "$add_entry22"; }
 $weblogtitle = str_replace("&#39;", "'", $weblog_info[title]);
 $entrytitle = str_replace("&#39;", "'", $title);
 $entrycontents = str_replace("&#39;", "'", stripslashes($contents));

 $subject = $admin_info[mailinglist_subject];
 $subject = str_replace("<weblogtitle>", $weblogtitle, $subject);
 $subject = str_replace("<weblogurl>", url("index", "$weblog_info[weblog]"), $subject);
 $subject = str_replace("<entrytitle>", $entrytitle, $subject);
 $subject = str_replace("<entryauthor>", $user_info[username], $subject);
 $subject = str_replace("<entrycontents>", $entrycontents, $subject);
 $subject = str_replace("<entryurl>", url("entry", "$weblog_info[weblog]", "", "$entry[e_id]"), $subject);
 $message = $admin_info[mailinglist_message];
 $message = str_replace("<weblogtitle>", $weblogtitle, $message);
 $message = str_replace("<weblogurl>", url("index", "$weblog_info[weblog]"), $message);
 $message = str_replace("<entrytitle>", $entrytitle, $message);
 $message = str_replace("<entryauthor>", $user_info[username], $message);
 $message = str_replace("<entrycontents>", $entrycontents, $message);
 $message = str_replace("<entryurl>", url("entry", "$weblog_info[weblog]", "", "$entry[e_id]"), $message);

 $subject = strip_tags($subject);
 $message = strip_tags($message);
 mail($weblog_info[mailing_list], $subject, $message, "From: $user_info[email]");
}


if($trackback_result == "") {
header("Location: view_entries.php");
exit();
} else {
echo $head;
echo "$add_entry30
<br><br>

$trackback_result

<br>
<form action='view_entries.php' method='POST'>
<input type='submit' class='button' value='$add_entry31'>
</form>
";
echo $foot;
exit();
}}









// GET CURRENT DATE AND TIME
$thism = cdate("n", timezone(time()));
$thisd = cdate("j", timezone(time()));
$thisy = cdate("Y", timezone(time()));
$thishour = cdate("g", timezone(time())); 
$thismin = cdate("i", timezone(time())); 
$thisampm = cdate("A", timezone(time())); 

// GET ENTRY DEFAULT
$entry_default = str_replace("'", "\'", $weblog_info[entry_default]);
$entry_default = str_replace("\r\n", "", $entry_default);

$podcast_file = "";
// GET FILES ARE SPECIFIED IN URL, CHECK FOR OWNERSHIP, ADD TO ENTRY DEFAULT
if(isset($_GET['up_id'])) { $up_id = $_GET['up_id']; } else { $up_id = ""; }
if(isset($_GET['t'])) { $t = $_GET['t']; } else { $t = "post"; }
if($up_id != "") { 

  $file = mysql_query("SELECT up_id, u_id, ext FROM bhost_uploads WHERE up_id='$up_id' AND u_id='$user_info[u_id]'");
  if(mysql_num_rows($file) != 1) { exit(); }
  elseif(mysql_num_rows($file) == 1) {
  $file = mysql_fetch_assoc($file);

  $file_owner = mysql_fetch_assoc(mysql_query("SELECT username FROM bhost_users WHERE u_id='$file[u_id]'"));

  $firstletter = strtolower(substr($file_owner[username], 0, 1));

  $path = str_replace("manager/add_entry.php", "", $_SERVER['PHP_SELF']);
  $path = "http://".$_SERVER['HTTP_HOST'].$path."uploads/$firstletter/$file_owner[username]/$file[up_id].$file[ext]";
  $filehtml = "";

  // GET EXTENSION
  $ext = $file[ext];

  // CHECK TO SEE IF POST OR PODCAST
  if($t == "pod") {
   $podcast_file = $path;
  } else {
   // IF FILE IS IMAGE, USE IMG TAG
   if($ext == "jpg" OR $ext == "jpeg" OR $ext == "gif" OR $ext == "png" OR $ext == "bmp") {
   
   // IF FILE IS NOT IMAGE, MAKE A LINK
   $filehtml = "<a href=\"$path\"><img src=\"$path$file[filename]\" border=\"0\"></a>";
   } else {
   $filehtml = "$add_entry25 <a href=\"$path$file[up_id]\">$file[filename]</a>";
   }}
   
   $entry_default = "$entry_default$filehtml";
  }
}


echo $head;
echo "
<h2>$add_entry1</h2>
$add_entry2
<br><br>

<script language='JavaScript'>
<!-- 
function preloader() {
bold_d = new Image(); 
bold_d.src = '../images/bold_d.gif';
italic_d = new Image(); 
italic_d.src = '../images/italic_d.gif';
underline_d = new Image(); 
underline_d.src = '../images/underline_d.gif';
left_just_d = new Image(); 
left_just_d.src = '../images/left_just_d.gif';
centre_d = new Image(); 
centre_d.src = '../images/centre_d.gif';
right_just_d = new Image(); 
right_just_d.src = '../images/right_just_d.gif';
justifyfull_d = new Image(); 
justifyfull_d.src = '../images/justifyfull_d.gif';
hr_d = new Image(); 
hr_d.src = '../images/hr_d.gif';
numbered_list_d = new Image(); 
numbered_list_d.src = '../images/numbered_list_d.gif';
list_d = new Image(); 
list_d.src = '../images/list_d.gif';
outdent_d = new Image(); 
outdent_d.src = '../images/outdent_d.gif';
indent_d = new Image(); 
indent_d.src = '../images/indent_d.gif';
textcolor_d = new Image(); 
textcolor_d.src = '../images/textcolor_d.gif';
bgcolor_d = new Image(); 
bgcolor_d.src = '../images/bgcolor_d.gif';
hyperlink_d = new Image(); 
hyperlink_d.src = '../images/hyperlink_d.gif';
image_d = new Image(); 
image_d.src = '../images/image_d.gif';
eraser_d = new Image(); 
eraser_d.src = '../images/eraser_d.gif';
smilie_d = new Image(); 
smilie_d.src = '../images/eraser_d.gif';
arrow = new Image(); 
arrow.src = '../images/arrow_right.gif';
arrow2 = new Image(); 
arrow2.src = '../images/arrow_down.gif';
}

// -->
</script>

<form name='info' action='add_entry.php' method='POST' onsubmit='return submitForm();'>
";





// SHOW TITLE IF ENABLED
if($weblog_info[showtitle] == "1") {
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td NOWRAP><font class='bold'>$add_entry3</font> &nbsp;</td>
<td><input type='text' class='text' size='70' name='title' maxlength='250'></td>
</tr>
</table>
<br>
";
} else {
echo "<input type='hidden' name='title' value=''>";
}




echo "
<table cellpadding='0' cellspacing='0' width='600'>
<tr>
<td>

<script language='JavaScript' type='text/javascript' src='../include/richtext.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
function fill() {
var oRTE = document.getElementById('contents');
if (document.all) {
window.document.preview.contents.value = frames['contents'].document.body.innerHTML;
} else {
window.document.preview.contents.value = oRTE.contentWindow.document.body.innerHTML;
}
window.document.preview.title.value = window.document.info.title.value;
window.document.preview.month.value = window.document.info.month.options[window.document.info.month.selectedIndex].value;
window.document.preview.day.value = window.document.info.day.options[window.document.info.day.selectedIndex].value;
window.document.preview.year.value = window.document.info.year.options[window.document.info.year.selectedIndex].value;
window.document.preview.hour.value = window.document.info.hour.options[window.document.info.hour.selectedIndex].value;
window.document.preview.minute.value = window.document.info.minute.options[window.document.info.minute.selectedIndex].value;
if(window.document.info.ampm.options) {
 window.document.preview.ampm.value = window.document.info.ampm.options[window.document.info.ampm.selectedIndex].value;
} else {
 window.document.preview.ampm.value = window.document.info.ampm.value;
}
if(window.document.info.ec_id.options) {
 window.document.preview.ec_id.value = window.document.info.ec_id.options[window.document.info.ec_id.selectedIndex].value;
} else {
 window.document.preview.ec_id.value = window.document.info.ec_id.value;
}
if(window.document.info.comments[0]) {
 if(window.document.info.comments[0].checked) {
 window.document.preview.comments.value = '1';
 } else {
 window.document.preview.comments.value = '0';
 }
} else {
 window.document.preview.comments.value = window.document.info.comments.value;
}
if(window.document.info.trackbacks[0]) {
 if(window.document.info.trackbacks[0].checked) {
 window.document.preview.trackbacks.value = '1';
 } else {
 window.document.preview.trackbacks.value = '0';
 }
} else {
 window.document.preview.trackbacks.value = window.document.info.trackbacks.value;
}
}
function submitForm() {
updateRTE('contents');
return true;
}
initRTE(\"../images/\", \"../include/\", \"\");
//-->
</script>
<noscript><font class='bold'>$add_entry23</font><br><textarea name='contents' id='contents_noscript' style='width: 600px; margin-bottom: 3px;' rows='8' cols='80' tabindex='2'>$entry_default</textarea></noscript>
<script language=\"JavaScript\" type=\"text/javascript\">
<!--
writeRichText('contents', '$entry_default', '600', 220, true, false, '$add_entry23');
//-->
</script>

<script language='JavaScript' type='text/javascript'>
<!--
function arrowdown() {
if (document.images) {
document.all.arrow.src = arrow2.src;
}}

function arrowright() {
if (document.images) {
document.all.arrow.src = arrow.src;
}}
";

if($weblog_info[default_advanced] == 1 OR $_GET[$t] == "pod") { echo "var state = 'block';"; } else { echo "var state = 'none';"; }

echo "
function showhide(layer_ref) { 
if (state == 'block') { 
state = 'none'; 
arrowright();
} else { 
state = 'block'; 
arrowdown();
} 
if (document.all) {
eval(\"document.all.\" + layer_ref + \".style.display = state\"); 
} 
if (document.layers) {
document.layers[layer_ref].display = state; 
} 
if (document.getElementById &&!document.all) { 
hza = document.getElementById(layer_ref); 
hza.style.display = state; 
}}
// -->
</script>
";

if($weblog_info[default_advanced] == 1 OR $_GET['t'] == "pod") { $arrow = "arrow_down.gif"; } else { $arrow = "arrow_right.gif"; }

echo "
<table cellpadding='0' cellspacing='0' class='advancedoptions'>
<tr>
<td class='advancedoptions' NOWRAP>
  <script language=\"JavaScript\" type=\"text/javascript\">
  <!--
  document.writeln('<img src=\'../images/$arrow\' border=\'0\' id=\'arrow\' name=\'arrow\' class=\'icon\'>');
  //-->
  </script>
  <noscript><img src='../images/arrow_down.gif' border='0' id='arrow' name='arrow' class='icon'></noscript>
  <font class='bold'><a href='#bottom' onClick=\"showhide('options')\">$add_entry18</a></font>
</td>
<td class='advancedoptions' align='right' NOWRAP>
";


// SHOW CHANGE TIME/DATE BOX
if($weblog_info[format_time] == "h:i A" OR $weblog_info[format_time] == "h:i" OR $weblog_info[format_time] == "H:i" OR $weblog_info[format_time] == "H\hi") { $z = "0"; }
if($weblog_info[format_time] == "H:i" | $weblog_info[format_time] == "H\hi") { $f = 1; $thishour = cdate("G", timezone(time())); }
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td NOWRAP>$add_entry5&nbsp;</td>
<td NOWRAP>
<select name='hour' class='small'>
"; if($f == 1) { echo "<option"; if($thishour == "0") { echo " SELECTED"; } echo " value='1'>0</option>"; } echo "
<option"; if($thishour == "1") { echo " SELECTED"; } echo " value='1'>".$z."1</option>
<option"; if($thishour == "2") { echo " SELECTED"; } echo " value='2'>".$z."2</option>
<option"; if($thishour == "3") { echo " SELECTED"; } echo " value='3'>".$z."3</option>
<option"; if($thishour == "4") { echo " SELECTED"; } echo " value='4'>".$z."4</option>
<option"; if($thishour == "5") { echo " SELECTED"; } echo " value='5'>".$z."5</option>
<option"; if($thishour == "6") { echo " SELECTED"; } echo " value='6'>".$z."6</option>
<option"; if($thishour == "7") { echo " SELECTED"; } echo " value='7'>".$z."7</option>
<option"; if($thishour == "8") { echo " SELECTED"; } echo " value='8'>".$z."8</option>
<option"; if($thishour == "9") { echo " SELECTED"; } echo " value='9'>".$z."9</option>
<option"; if($thishour == "10") { echo " SELECTED"; } echo " value='10'>10</option>
<option"; if($thishour == "11") { echo " SELECTED"; } echo " value='11'>11</option>
<option"; if($thishour == "12") { echo " SELECTED"; } echo " value='12'>12</option>
";
if($f == 1) {
echo "
<option"; if($thishour == "13") { echo " SELECTED"; } echo " value='13'>13</option>
<option"; if($thishour == "14") { echo " SELECTED"; } echo " value='14'>14</option>
<option"; if($thishour == "15") { echo " SELECTED"; } echo " value='15'>15</option>
<option"; if($thishour == "16") { echo " SELECTED"; } echo " value='16'>16</option>
<option"; if($thishour == "17") { echo " SELECTED"; } echo " value='17'>17</option>
<option"; if($thishour == "18") { echo " SELECTED"; } echo " value='18'>18</option>
<option"; if($thishour == "19") { echo " SELECTED"; } echo " value='19'>19</option>
<option"; if($thishour == "20") { echo " SELECTED"; } echo " value='20'>20</option>
<option"; if($thishour == "21") { echo " SELECTED"; } echo " value='21'>21</option>
<option"; if($thishour == "22") { echo " SELECTED"; } echo " value='22'>22</option>
<option"; if($thishour == "23") { echo " SELECTED"; } echo " value='23'>23</option>
";
}
echo "
</select>
<img src='../images/colon.gif' border='0'><select name='minute' class='small'>
<option"; if($thismin == "00") { echo " SELECTED"; } echo " value='00'>00</option>
<option"; if($thismin == "01") { echo " SELECTED"; } echo " value='01'>01</option>
<option"; if($thismin == "02") { echo " SELECTED"; } echo " value='02'>02</option>
<option"; if($thismin == "03") { echo " SELECTED"; } echo " value='03'>03</option>
<option"; if($thismin == "04") { echo " SELECTED"; } echo " value='04'>04</option>
<option"; if($thismin == "05") { echo " SELECTED"; } echo " value='05'>05</option>
<option"; if($thismin == "06") { echo " SELECTED"; } echo " value='06'>06</option>
<option"; if($thismin == "07") { echo " SELECTED"; } echo " value='07'>07</option>
<option"; if($thismin == "08") { echo " SELECTED"; } echo " value='08'>08</option>
<option"; if($thismin == "09") { echo " SELECTED"; } echo " value='09'>09</option>
<option"; if($thismin == "10") { echo " SELECTED"; } echo " value='10'>10</option>
<option"; if($thismin == "11") { echo " SELECTED"; } echo " value='11'>11</option>
<option"; if($thismin == "12") { echo " SELECTED"; } echo " value='12'>12</option>
<option"; if($thismin == "13") { echo " SELECTED"; } echo " value='13'>13</option>
<option"; if($thismin == "14") { echo " SELECTED"; } echo " value='14'>14</option>
<option"; if($thismin == "15") { echo " SELECTED"; } echo " value='15'>15</option>
<option"; if($thismin == "16") { echo " SELECTED"; } echo " value='16'>16</option>
<option"; if($thismin == "17") { echo " SELECTED"; } echo " value='17'>17</option>
<option"; if($thismin == "18") { echo " SELECTED"; } echo " value='18'>18</option>
<option"; if($thismin == "19") { echo " SELECTED"; } echo " value='19'>19</option>
<option"; if($thismin == "20") { echo " SELECTED"; } echo " value='20'>20</option>
<option"; if($thismin == "21") { echo " SELECTED"; } echo " value='21'>21</option>
<option"; if($thismin == "22") { echo " SELECTED"; } echo " value='22'>22</option>
<option"; if($thismin == "23") { echo " SELECTED"; } echo " value='23'>23</option>
<option"; if($thismin == "24") { echo " SELECTED"; } echo " value='24'>24</option>
<option"; if($thismin == "25") { echo " SELECTED"; } echo " value='25'>25</option>
<option"; if($thismin == "26") { echo " SELECTED"; } echo " value='26'>26</option>
<option"; if($thismin == "27") { echo " SELECTED"; } echo " value='27'>27</option>
<option"; if($thismin == "28") { echo " SELECTED"; } echo " value='28'>28</option>
<option"; if($thismin == "29") { echo " SELECTED"; } echo " value='29'>29</option>
<option"; if($thismin == "30") { echo " SELECTED"; } echo " value='30'>30</option>
<option"; if($thismin == "31") { echo " SELECTED"; } echo " value='31'>31</option>
<option"; if($thismin == "32") { echo " SELECTED"; } echo " value='32'>32</option>
<option"; if($thismin == "33") { echo " SELECTED"; } echo " value='33'>33</option>
<option"; if($thismin == "34") { echo " SELECTED"; } echo " value='34'>34</option>
<option"; if($thismin == "35") { echo " SELECTED"; } echo " value='35'>35</option>
<option"; if($thismin == "36") { echo " SELECTED"; } echo " value='36'>36</option>
<option"; if($thismin == "37") { echo " SELECTED"; } echo " value='37'>37</option>
<option"; if($thismin == "38") { echo " SELECTED"; } echo " value='38'>38</option>
<option"; if($thismin == "39") { echo " SELECTED"; } echo " value='39'>39</option>
<option"; if($thismin == "40") { echo " SELECTED"; } echo " value='40'>40</option>
<option"; if($thismin == "41") { echo " SELECTED"; } echo " value='41'>41</option>
<option"; if($thismin == "42") { echo " SELECTED"; } echo " value='42'>42</option>
<option"; if($thismin == "43") { echo " SELECTED"; } echo " value='43'>43</option>
<option"; if($thismin == "44") { echo " SELECTED"; } echo " value='44'>44</option>
<option"; if($thismin == "45") { echo " SELECTED"; } echo " value='45'>45</option>
<option"; if($thismin == "46") { echo " SELECTED"; } echo " value='46'>46</option>
<option"; if($thismin == "47") { echo " SELECTED"; } echo " value='47'>47</option>
<option"; if($thismin == "48") { echo " SELECTED"; } echo " value='48'>48</option>
<option"; if($thismin == "49") { echo " SELECTED"; } echo " value='49'>49</option>
<option"; if($thismin == "50") { echo " SELECTED"; } echo " value='50'>50</option>
<option"; if($thismin == "51") { echo " SELECTED"; } echo " value='51'>51</option>
<option"; if($thismin == "52") { echo " SELECTED"; } echo " value='52'>52</option>
<option"; if($thismin == "53") { echo " SELECTED"; } echo " value='53'>53</option>
<option"; if($thismin == "54") { echo " SELECTED"; } echo " value='54'>54</option>
<option"; if($thismin == "55") { echo " SELECTED"; } echo " value='55'>55</option>
<option"; if($thismin == "56") { echo " SELECTED"; } echo " value='56'>56</option>
<option"; if($thismin == "57") { echo " SELECTED"; } echo " value='57'>57</option>
<option"; if($thismin == "58") { echo " SELECTED"; } echo " value='58'>58</option>
<option"; if($thismin == "59") { echo " SELECTED"; } echo " value='59'>59</option>
</select>
";
if($weblog_info[format_time] == "g:i A" OR $weblog_info[format_time] == "h:i A") {
echo "
<select name='ampm' class='small'>
<option"; if($thisampm == "AM") { echo " SELECTED"; } echo " value='AM'>AM</option>
<option"; if($thisampm == "PM") { echo " SELECTED"; } echo " value='PM'>PM</option>
</select>&nbsp;
";
} elseif($weblog_info[format_time] == "H:i" | $weblog_info[format_time] == "H\hi") { 
echo "<input type='hidden' name='ampm' value=''>";
} else {
echo "<input type='hidden' name='ampm' value='$thisampm'>";
}

// MONTHBOX
if($weblog_info[format_date] == "n/j/Y" OR $weblog_info[format_date] == "n.j.Y" OR $weblog_info[format_date] == "n-j-Y" OR $weblog_info[format_date] == "Y/n/j" OR $weblog_info[format_date] == "Y-n-j" OR $weblog_info[format_date] == "Ynj" OR $weblog_info[format_date] == "j/n/Y" OR $weblog_info[format_date] == "j.n.Y") {
 $mf = "n";
} elseif($weblog_info[format_date] == "Y-m-d") { 
 $mf = "m";
} elseif($weblog_info[format_date] == "M. j, Y" OR $weblog_info[format_date] == "l" OR $weblog_info[format_date] == "Y-M-j" OR $weblog_info[format_date] == "D-j-M-Y" OR $weblog_info[format_date] == "D j M Y" OR $weblog_info[date_format] == "j-M-Y") {
 $mf = "M";
} elseif($weblog_info[format_date] == "F j, Y" OR $weblog_info[format_date] == "l, F j, Y" OR $weblog_info[format_date] == "l, F j" OR $weblog_info[format_date] == "j F Y" OR $weblog_info[format_date] == "D j F Y" OR $weblog_info[format_date] == "l j F Y") {
 $mf = "F";
}

$mbox = "
<select name='month' class='small'>
<option"; if($thism == "1") { $mbox .= " SELECTED"; } $mbox .= " value='1'>".cdate("$mf", "864000")."</option>
<option"; if($thism == "2") { $mbox .= " SELECTED"; } $mbox .= " value='2'>".cdate("$mf", "3542400")."</option>
<option"; if($thism == "3") { $mbox .= " SELECTED"; } $mbox .= " value='3'>".cdate("$mf", "6220800")."</option>
<option"; if($thism == "4") { $mbox .= " SELECTED"; } $mbox .= " value='4'>".cdate("$mf", "8899200")."</option>
<option"; if($thism == "5") { $mbox .= " SELECTED"; } $mbox .= " value='5'>".cdate("$mf", "11577600")."</option>
<option"; if($thism == "6") { $mbox .= " SELECTED"; } $mbox .= " value='6'>".cdate("$mf", "14256000")."</option>
<option"; if($thism == "7") { $mbox .= " SELECTED"; } $mbox .= " value='7'>".cdate("$mf", "16934400")."</option>
<option"; if($thism == "8") { $mbox .= " SELECTED"; } $mbox .= " value='8'>".cdate("$mf", "19612800")."</option>
<option"; if($thism == "9") { $mbox .= " SELECTED"; } $mbox .= " value='9'>".cdate("$mf", "22291200")."</option>
<option"; if($thism == "10") { $mbox .= " SELECTED"; } $mbox .= " value='10'>".cdate("$mf", "24969600")."</option>
<option"; if($thism == "11") { $mbox .= " SELECTED"; } $mbox .= " value='11'>".cdate("$mf", "27648000")."</option>
<option"; if($thism == "12") { $mbox .= " SELECTED"; } $mbox .= " value='12'>".cdate("$mf", "30326400")."</option>
</select>
";


// DAYBOX
if($weblog_info[format_date] == "Y-m-d") { $z = "0"; } else { $z = ""; }
$dbox = "
<select name='day' class='small'>
<option"; if($thisd == "1") { $dbox .= " SELECTED"; } $dbox .= " value='1'>".$z."1</option>
<option"; if($thisd == "2") { $dbox .= " SELECTED"; } $dbox .= " value='2'>".$z."2</option>
<option"; if($thisd == "3") { $dbox .= " SELECTED"; } $dbox .= " value='3'>".$z."3</option>
<option"; if($thisd == "4") { $dbox .= " SELECTED"; } $dbox .= " value='4'>".$z."4</option>
<option"; if($thisd == "5") { $dbox .= " SELECTED"; } $dbox .= " value='5'>".$z."5</option>
<option"; if($thisd == "6") { $dbox .= " SELECTED"; } $dbox .= " value='6'>".$z."6</option>
<option"; if($thisd == "7") { $dbox .= " SELECTED"; } $dbox .= " value='7'>".$z."7</option>
<option"; if($thisd == "8") { $dbox .= " SELECTED"; } $dbox .= " value='8'>".$z."8</option>
<option"; if($thisd == "9") { $dbox .= " SELECTED"; } $dbox .= " value='9'>".$z."9</option>
<option"; if($thisd == "10") { $dbox .= " SELECTED"; } $dbox .= " value='10'>10</option>
<option"; if($thisd == "11") { $dbox .= " SELECTED"; } $dbox .= " value='11'>11</option>
<option"; if($thisd == "12") { $dbox .= " SELECTED"; } $dbox .= " value='12'>12</option>
<option"; if($thisd == "13") { $dbox .= " SELECTED"; } $dbox .= " value='13'>13</option>
<option"; if($thisd == "14") { $dbox .= " SELECTED"; } $dbox .= " value='14'>14</option>
<option"; if($thisd == "15") { $dbox .= " SELECTED"; } $dbox .= " value='15'>15</option>
<option"; if($thisd == "16") { $dbox .= " SELECTED"; } $dbox .= " value='16'>16</option>
<option"; if($thisd == "17") { $dbox .= " SELECTED"; } $dbox .= " value='17'>17</option>
<option"; if($thisd == "18") { $dbox .= " SELECTED"; } $dbox .= " value='18'>18</option>
<option"; if($thisd == "19") { $dbox .= " SELECTED"; } $dbox .= " value='19'>19</option>
<option"; if($thisd == "20") { $dbox .= " SELECTED"; } $dbox .= " value='20'>20</option>
<option"; if($thisd == "21") { $dbox .= " SELECTED"; } $dbox .= " value='21'>21</option>
<option"; if($thisd == "22") { $dbox .= " SELECTED"; } $dbox .= " value='22'>22</option>
<option"; if($thisd == "23") { $dbox .= " SELECTED"; } $dbox .= " value='23'>23</option>
<option"; if($thisd == "24") { $dbox .= " SELECTED"; } $dbox .= " value='24'>24</option>
<option"; if($thisd == "25") { $dbox .= " SELECTED"; } $dbox .= " value='25'>25</option>
<option"; if($thisd == "26") { $dbox .= " SELECTED"; } $dbox .= " value='26'>26</option>
<option"; if($thisd == "27") { $dbox .= " SELECTED"; } $dbox .= " value='27'>27</option>
<option"; if($thisd == "28") { $dbox .= " SELECTED"; } $dbox .= " value='28'>28</option>
<option"; if($thisd == "29") { $dbox .= " SELECTED"; } $dbox .= " value='29'>29</option>
<option"; if($thisd == "30") { $dbox .= " SELECTED"; } $dbox .= " value='30'>30</option>
<option"; if($thisd == "31") { $dbox .= " SELECTED"; } $dbox .= " value='31'>31</option>
</select> 
";

// YEARBOX
$ybox = " 
<select name='year' class='small'>
<option"; if($thisy == "2000") { $ybox .= " SELECTED"; } $ybox .= " value='2000'>2000</option>
<option"; if($thisy == "2001") { $ybox .= " SELECTED"; } $ybox .= " value='2001'>2001</option>
<option"; if($thisy == "2002") { $ybox .= " SELECTED"; } $ybox .= " value='2002'>2002</option>
<option"; if($thisy == "2003") { $ybox .= " SELECTED"; } $ybox .= " value='2003'>2003</option>
<option"; if($thisy == "2004") { $ybox .= " SELECTED"; } $ybox .= " value='2004'>2004</option>
<option"; if($thisy == "2005") { $ybox .= " SELECTED"; } $ybox .= " value='2005'>2005</option>
<option"; if($thisy == "2006") { $ybox .= " SELECTED"; } $ybox .= " value='2006'>2006</option>
<option"; if($thisy == "2007") { $ybox .= " SELECTED"; } $ybox .= " value='2007'>2007</option>
<option"; if($thisy == "2008") { $ybox .= " SELECTED"; } $ybox .= " value='2008'>2008</option>
<option"; if($thisy == "2009") { $ybox .= " SELECTED"; } $ybox .= " value='2009'>2009</option>
<option"; if($thisy == "2010") { $ybox .= " SELECTED"; } $ybox .= " value='2010'>2010</option>
<option"; if($thisy == "2011") { $ybox .= " SELECTED"; } $ybox .= " value='2011'>2011</option>
<option"; if($thisy == "2012") { $ybox .= " SELECTED"; } $ybox .= " value='2012'>2012</option>
<option"; if($thisy == "2013") { $ybox .= " SELECTED"; } $ybox .= " value='2013'>2013</option>
<option"; if($thisy == "2014") { $ybox .= " SELECTED"; } $ybox .= " value='2014'>2014</option>
<option"; if($thisy == "2015") { $ybox .= " SELECTED"; } $ybox .= " value='2015'>2015</option>
<option"; if($thisy == "2016") { $ybox .= " SELECTED"; } $ybox .= " value='2016'>2016</option>
<option"; if($thisy == "2017") { $ybox .= " SELECTED"; } $ybox .= " value='2017'>2017</option>
<option"; if($thisy == "2018") { $ybox .= " SELECTED"; } $ybox .= " value='2018'>2018</option>
<option"; if($thisy == "2019") { $ybox .= " SELECTED"; } $ybox .= " value='2019'>2019</option>
<option"; if($thisy == "2020") { $ybox .= " SELECTED"; } $ybox .= " value='2020'>2020</option>
</select>";

if($weblog_info[format_date] == "n/j/Y" OR $weblog_info[format_date] == "n.j.Y" OR $weblog_info[format_date] == "n-j-Y" OR $weblog_info[format_date] == "M. j, Y" OR $weblog_info[format_date] == "F j, Y" OR $weblog_info[format_date] == "l, F j, Y" OR $weblog_info[format_date] == "l, F j") {
$boxes = "$mbox $dbox $ybox";
} elseif($weblog_info[format_date] == "Y/n/j" OR $weblog_info[format_date] == "Y-n-j" OR $weblog_info[format_date] == "Y-m-d" OR $weblog_info[format_date] == "Ynj" OR $weblog_info[format_date] == "Y-M-j") {
$boxes = "$ybox $mbox $dbox";
} elseif($weblog_info[format_date] == "j/n/Y" OR $weblog_info[format_date] == "j.n.Y" OR $weblog_info[format_date] == "j F Y" OR $weblog_info[format_date] == "D-j-M-Y" OR $weblog_info[format_date] == "D j M Y" OR $weblog_info[format_date] == "D j F Y" OR $weblog_info[format_date] == "l j F Y" OR $weblog_info[format_date] == "j-M-Y") {
$boxes = "$dbox $mbox $ybox";
} elseif($weblog_info[format_date] == "l, F j" OR $weblog_info[format_date] == "l") {
$boxes = "$mbox $dbox"; $noyear = 1;
}


if($noyear == 1) { echo "<input type='hidden' name='year' value='$thisy'>"; }

echo "
$boxes
"; tip2("19", "20"); echo "
</td></tr></table>
</td>
</tr>
</table>
";






// SHOW ADVANCED OPTIONS TABLE (WITH NOSCRIPT IF JAVASCRIPT ISNT ENABLED)
// OR IF USER HAS CHOSEN TO ALWAYS SHOW

if($weblog_info[default_advanced] == 1 OR $_GET['t'] == "pod") { $display = " style='display: block;'"; }

echo "
<noscript><style type='text/css'>div.advancedoptions { display: block; }</style></noscript>

<div name='options' id='options' class='advancedoptions'$display>
<table cellpadding='0' cellspacing='0' class='entryform'>
";


// SHOW PRIVACY BOX
if($owner_group_info[allow_privacy] == "1") {
echo "
<tr>
<td class='entryform1'>$add_entry7</td>
<td NOWRAP class='entryform2'>
<select name='privacy' class='small'>
<option value='3'"; if($weblog_info[default_privacy] == "3") { echo " SELECTED"; } echo ">$add_entry8</option>
<option value='2'"; if($weblog_info[default_privacy] == "2") { echo " SELECTED"; } echo ">$add_entry9</option> 
"; if($owner_group_info[allow_friends] == "1") { echo "<option value='1'"; if($weblog_info[default_privacy] == "1") { echo " SELECTED"; } echo ">$add_entry10</option>"; } echo "
<option value='0'"; if($weblog_info[default_privacy] == "0") { echo " SELECTED"; } echo ">$add_entry11</option>
</select>";tip2("21", "22");echo"
</td>
</tr>
";
} else {
echo "<input type='hidden' name='privacy' value='3'>";
}




// SHOW ENTRY CATEGORY BOX
$entry_cats = mysql_query("SELECT * FROM bhost_entrycategories WHERE w_id='$weblog_info[w_id]'");
$total_cats = mysql_num_rows($entry_cats);
if($owner_group_info[allow_entry_cat] == "1" AND $total_cats > 0) {
echo "
<tr>
<td class='entryform1'>$add_entry6</td>
<td NOWRAP class='entryform2'>

<table cellpadding='0' cellspacing='0'>
<tr><td>
<select name='ec_id' class='small'>
<option value='0' SELECTED>$add_entry12</option>
";
while($entry_cat_info = mysql_fetch_assoc($entry_cats)) {
echo "<option value='$entry_cat_info[ec_id]'>$entry_cat_info[name]</option>";
}
echo "
</select>
</td><td>
";tip2("52", "53");echo"</td>
</tr>
</table>

</td>
</tr>
";
} else {
echo "<input type='hidden' name='ec_id' value='0'>";
}




// SHOW COMMENTS BOX
if($owner_group_info[allow_comments] == "1" & $weblog_info[show_comments] != "0") {
echo "
<tr>
<td class='entryform1'>$add_entry13</td>
<td NOWRAP class='entryform2'>
 <table height='21' cellpadding='0' cellspacing='0'><tr>
 <td><input type='radio' name='comments' value='1'"; if($weblog_info[default_comments] == "1") { echo " CHECKED"; } echo "></td><td NOWRAP><span onClick='window.document.info.comments[0].checked=true;'>$add_entry14</span> &nbsp;</td>
 <td><input type='radio' name='comments' value='0'"; if($weblog_info[default_comments] == "0") { echo " CHECKED"; } echo "></td><td NOWRAP><span onClick='window.document.info.comments[1].checked=true;'>$add_entry15</span></td><td style='padding-left: 2px;'>";tip2("23", "24");echo"</td>
 </tr></table>
</td>
</tr>
";
} else {
echo "<input type='hidden' name='comments' value='0'>";
}


// SHOW TRACKBACK BOX
if($owner_group_info[allow_trackback] == "1") {
echo "
<tr>
<td class='entryform1'>$add_entry34</td>
<td NOWRAP class='entryform2'>
 <table height='21' cellpadding='0' cellspacing='0'><tr>
 <td><input type='radio' name='trackbacks' value='1'"; if($weblog_info[default_trackbacks] == "1") { echo " CHECKED"; } echo "></td><td NOWRAP><span onClick='window.document.info.trackbacks[0].checked=true;'>$add_entry35</span> &nbsp;</td>
 <td><input type='radio' name='trackbacks' value='0'"; if($weblog_info[default_trackbacks] == "0") { echo " CHECKED"; } echo "></td><td NOWRAP><span onClick='window.document.info.trackbacks[1].checked=true;'>$add_entry36</span></td><td style='padding-left: 2px;'>";tip2("60", "61");echo"</td>
 </tr></table>
</td>
</tr>
";
} else {
echo "<input type='hidden' name='trackbacks' value='0'>";
}



// SHOW MAILING LIST BOX
if($owner_group_info[allow_mailinglist] == "1" AND str_replace(" ", "", $weblog_info[mailing_list] != "")) {
echo "
<tr>
<td class='entryform1'>$add_entry17</td>
<td NOWRAP class='entryform2'>
  <table cellpadding='0' cellspacing='0'>
  <tr>
  <td><input type='radio' name='send_mail' value='1'></td><td><span onClick='window.document.info.send_mail[0].checked=true;'>$add_entry14</span> &nbsp;</td>
  <td><input type='radio' name='send_mail' value='0' CHECKED></td><td><span onClick='window.document.info.send_mail[1].checked=true;'>$add_entry15</span></td></td><td style='padding-left: 2px;'>";tip2("25", "26");echo"</td>
  </tr>
  </table>
</td>
</tr>
";
} else {
echo "

<input type='hidden' name='send_mail' value='0'>
";
}



// SHOW TRACKBACK BOX
if($owner_group_info[allow_trackback] == "1") {
echo "
<tr>
<td class='entryform1'>$add_entry16</td>
<td NOWRAP class='entryform2'>
<input type='text' class='text' name='tb_to_ping' value='' size='50' style='margin-left: 4px;'>";tip2("56", "57");echo"
</td>
</tr>
";
} else {
echo "<input type='hidden' name='tb_to_ping' value=''>";
}



// SHOW PODCASTING BOX
if($owner_group_info[allow_podcast] == "1") {
echo "
<tr>
<td class='entryform1'>$add_entry24</td>
<td NOWRAP class='entryform2'>
<input type='text' class='text' name='podcast' value='$podcast_file' size='50' style='margin-left: 4px;'>";tip2("3", "4");
if($weblog_info[podcast_on] != "1") { echo "$add_entry39"; } echo "
</td>
</tr>
";
} else {
echo "<input type='hidden' name='podcast' value=''>";
}


echo "
</table>
</div>
</td>
</tr>
</table>
";






// SUBMIT BUTTONS
echo "
<br>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><input type='submit' name='submit' class='button' value='$add_entry19'>&nbsp;</td>
<td><input type='submit' name='submit' class='button' value='$add_entry20'>&nbsp;</td>
<input type='hidden' name='task' value='doadd'>
</form>
<form action='../previewentry.php' method='POST' target='_blank' name='preview'>
<td>
<input type='submit' name='submit' class='button' value='$add_entry21' onClick='fill();'>
<input type='hidden' name='title' value=''>
<input type='hidden' name='contents' value=''>
<input type='hidden' name='month' value=''>
<input type='hidden' name='day' value=''>
<input type='hidden' name='year' value=''>
<input type='hidden' name='hour' value=''>
<input type='hidden' name='minute' value=''>
<input type='hidden' name='ampm' value=''>
<input type='hidden' name='comments' value=''>
<input type='hidden' name='trackbacks' value=''>
<input type='hidden' name='ec_id' value=''>
<input type='hidden' name='author_u_id' value='$user_info[u_id]'>
</td>
</form>
</tr>
</table>
<a name='bottom'></a>


<script language=\"JavaScript\" type=\"text/javascript\">
<!--
appendEvent = function(el, evname, func) {
 if (el.attachEvent) { // IE
   el.attachEvent('on' + evname, func);
 } else if (el.addEventListener) { // Gecko / W3C
   el.addEventListener(evname, func, true);
 } else {
   el['on' + evname] = func;
 }
};
appendEvent(window, 'load', windowonload);

function windowonload() { "; if($weblog_info[showtitle] == "1") { echo "window.document.info.title.focus();"; } echo " preloader(); }

//-->
</script>
";

echo $foot;
?>