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

if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "none"; }
if(isset($_POST['e_id'])) { $e_id = $_POST['e_id']; } elseif(isset($_GET['e_id'])) { $e_id = $_GET['e_id']; } else { exit(); } 
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_entries WHERE e_id='$e_id' AND w_id='$weblog_info[w_id]'"));
if(($user_status != "owner" & $user_status != "admin") & ($user_status == "member" & $user_info[u_id] != $entry[author_u_id])) { header("Location: view_entries.php"); exit(); }



if($task == "doedit") {
$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 = "";
$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'];
$submit = stripslashes($_POST['submit']);

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

// 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 != "") {
 $ext = strtolower(str_replace(".", "", strtolower(strrchr($podcast, "."))));
 $extensions = explode(",", strtolower($group_info[podcast_extensions]));
 if($entry[podcast] == "") { $add_to_contents = str_replace("'", "&#39;", "<p class=\"podcast\"><a href=\"$podcast\">$edit_entry36</a> (<a href=\"".url("podcast", "$weblog_info[weblog]")."\">$edit_entry37</a>)</p>"); } else { $add_to_contents = ""; }
 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;


// UPDATE ENTRY
if(htmlentities($submit, ENT_QUOTES) == htmlentities(html_entity_decode($edit_entry1, ENT_QUOTES), ENT_QUOTES) | htmlentities($submit, ENT_QUOTES) == htmlentities(html_entity_decode($edit_entry2, ENT_QUOTES), ENT_QUOTES)) { 
if(htmlentities($submit, ENT_QUOTES) == htmlentities(html_entity_decode($edit_entry2, ENT_QUOTES), ENT_QUOTES)) { $draft = "1"; } else { $draft = "0"; }


mysql_query("UPDATE bhost_entries SET ec_id='$ec_id', title='$title', contents='$contents', draft='$draft', privacy='$privacy', date='$date', comments='$comments', trackbacks='$trackbacks', podcast='$podcast', podcast_size='$podcast_size', podcast_type='$podcast_type' WHERE e_id='$e_id' AND w_id='$weblog_info[w_id]'");



$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_entries WHERE e_id='$e_id'"));
$author_info = mysql_fetch_assoc(mysql_query("SELECT * FROM bhost_users WHERE u_id='$entry[author_u_id]'"));
$trackback_result = "";
$trackback_pinged = explode(" ", $entry[tb_pinged]);
include "../include/trackback_cls.php";
$trackback = new Trackback("$weblog_info[title]", "$author_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) {
  if(!in_array($tb_url, $trackback_pinged)) {
   $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 = "$edit_entry23<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 = "$edit_entry24"; } 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> - $edit_entry25<br>";
        } elseif($response == "2") {
          $trackback_result .= "<i>$tb_to_ping_urls[$tb]</i> - $edit_entry26<br>";
          $tb_pinged .= "$tb_to_ping_urls[$tb] ";
        } else {
          $trackback_result .= "<i>$tb_to_ping_urls[$tb]</i> - $edit_entry27<br>";
        }
      }
    }
    $tb_pinged = trim(trim($tb_pinged)." ".$entry[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]'");
  


echo $head;
echo "$edit_entry28
<br><br>
  
$trackback_result

<br>
<form action='view_entries.php' method='POST'>
<input type='submit' class='button' value='$edit_entry29'>
</form>
";

echo $foot;
exit();

}


header("Location: view_entries.php");
exit();
} else {
header("Location: view_entries.php");
exit();
}

}







if($task == "none") {

// GET ORIGINAL ENTRY DATE AND TIME
$thism = cdate("n", timezone($entry[date]));
$thisd = cdate("j", timezone($entry[date]));
$thisy = cdate("Y", timezone($entry[date]));
$thishour = cdate("g", timezone($entry[date])); 
$thismin = cdate("i", timezone($entry[date])); 
$thisampm = cdate("A", timezone($entry[date]));

$contents = str_replace("\r\n", " ", $entry[contents]);

echo $head;
echo "
<h2>$edit_entry3</h2>
$edit_entry4
<br><br>

<script language='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', preloader);

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';
arrow = new Image(); 
arrow.src = '../images/arrow_right.gif';
arrow2 = new Image(); 
arrow2.src = '../images/arrow_down.gif';
}
// -->
</script>


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

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

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.e_id.value = window.document.info.e_id.value;
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'>$edit_entry6</font><br><textarea name='contents' style='width: 600px; margin-bottom: 3px;' rows='8' cols='80' tabindex='2'>$contents</textarea></noscript>
<script language=\"JavaScript\" type=\"text/javascript\">
<!--
writeRichText('contents', '$contents', '600', 220, true, false, '$edit_entry6');
//-->
</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) { 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) { $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')\">$edit_entry22</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" OR $weblog_info[format_time] == "H\hi") { $f = 1; $thishour = cdate("G", timezone(time())); }
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td NOWRAP>$edit_entry7&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" OR $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) { $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'>$edit_entry9</td>
<td class='entryform2'>
<select name='privacy' class='small'>
<option value='3'"; if($entry[privacy] == "3") { echo " SELECTED"; } echo ">$edit_entry10</option>
<option value='2'"; if($entry[privacy] == "2") { echo " SELECTED"; } echo ">$edit_entry11</option>
"; if($owner_group_info[allow_friends] == "1") { echo "<option value='1'"; if($entry[privacy] == "1") { echo " SELECTED"; } echo ">$edit_entry12</option>"; } echo "
<option value='0'"; if($entry[privacy] == "0") { echo " SELECTED"; } echo ">$edit_entry13</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'>$edit_entry8</td>
<td NOWRAP class='entryform2'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td>
<select name='ec_id' class='small'>
<option value='0'"; if($entry[ec_id] == "0") { echo " SELECTED"; } echo ">$edit_entry14</option>
";
$entry_cats = mysql_query("SELECT * FROM bhost_entrycategories WHERE w_id='$weblog_info[w_id]'");
while($entry_cat_info = mysql_fetch_assoc($entry_cats)) {
echo "<option value='$entry_cat_info[ec_id]'"; if($entry[ec_id] == $entry_cat_info[ec_id]) { echo " SELECTED"; } echo ">$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'>$edit_entry15</td>
<td class='entryform2'>
 <table height='21' cellpadding='0' cellspacing='0'><tr>
 <td><input type='radio' name='comments' value='1'"; if($entry[comments] == "1") { echo " CHECKED"; } echo "></td><td NOWRAP>$edit_entry16</td>
 <td><input type='radio' name='comments' value='0'"; if($entry[comments] == "0") { echo " CHECKED"; } echo "></td><td NOWRAP>$edit_entry17</td><td>";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'>$edit_entry30</td>
<td NOWRAP class='entryform2'>
 <table height='21' cellpadding='0' cellspacing='0'><tr>
 <td><input type='radio' name='trackbacks' value='1'"; if($entry[trackbacks] == "1") { echo " CHECKED"; } echo "></td><td NOWRAP><span onClick='window.document.info.trackbacks[0].checked=true;'>$edit_entry31</span> &nbsp;</td>
 <td><input type='radio' name='trackbacks' value='0'"; if($entry[trackbacks] == "0") { echo " CHECKED"; } echo "></td><td NOWRAP><span onClick='window.document.info.trackbacks[1].checked=true;'>$edit_entry32</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 TRACKBACK URL
if($owner_group_info[allow_trackback] == "1") {
echo "
<tr>
<td class='entryform1'>$edit_entry18</td>
<td NOWRAP class='entryform2'>
<input type='text' class='text' name='tb_to_ping' value='$entry[tb_to_ping]' size='50' style='margin-left: 4px;'>";tip2("56", "57");echo"
</td>
</tr>
";
if(str_replace(" ", "", $entry[tb_pinged]) != "") {
echo "
<tr>
<td class='entryform1'>$edit_entry33</td>
<td NOWRAP class='entryform2'>
<font class='gray'>
".preg_replace('|\s+|', '<br>', $entry[tb_pinged])."
</font>
</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'>$edit_entry34</td>
<td NOWRAP class='entryform2'>
<input type='text' class='text' name='podcast' value='$entry[podcast]' size='50' style='margin-left: 4px;'>";tip2("3", "4");
if($weblog_info[podcast_on] != "1") { echo "$edit_entry35"; } echo "
</td>
</tr>
";
} else {
echo "<input type='hidden' name='podcast' value=''>";
}


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

<br>

<table cellpadding='0' cellspacing='0'>
<tr>
<td>
<input type='submit' class='button' name='submit' value='$edit_entry1'>&nbsp;
</td>
<td>
<input type='submit' class='button' name='submit' value='$edit_entry2'>&nbsp;
</td>
<input type='hidden' name='task' value='doedit'>
<input type='hidden' name='e_id' value='$e_id'>
</form>
<form action='../previewentry.php' method='POST' target='_blank' name='preview'>
<td>
<input type='submit' name='submit' class='button' value='$edit_entry19' onClick='fill();'>&nbsp;
<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='e_id' value=''>
<input type='hidden' name='author_u_id' value='$entry[author_u_id]'>
</td>
</form>
<form action='edit_entry.php' method='POST'>
<td>
<input type='submit' class='button' name='submit' value='$edit_entry20'>&nbsp;
<input type='hidden' name='task' value='doedit'>
<input type='hidden' name='e_id' value='$e_id'>
</td>
</form>
</tr>
</table>
<a name='bottom'>&nbsp;</a>
";

echo $foot;

}
?>