Location: PHPKode > projects > TheoPlan > pm/admin/admin.php
<?php
	/*
		Copyright (C) 2003-2004 MJG/04-Inconceivable.org
		See file LICENSE for licensing details.
		See file VERSION for versioning/author/source details
		See file CHANGELOG for changes from version to version
	*/
	// Include configuration data
//require_once('version.inc');
//require_once('header.inc');
require_once('../dbaccess.inc');
	include("../global_config.inc.php");

	// connect to the database
	$CONF['dbConn'] = OpenDB();

	// Authenticate via the set cookie from index.php
	if ( md5($CONF['adm_user'] . $CONF['adm_pass']) != $_COOKIE['mcal_adm_auth'] )
	{
		header("Location: index.php?year=" . $FORM['year'] . "&month=" . $FORM['month'] . "&today=" . $FORM['today'] . "\n\n");
		exit(1);
	}
?>


<html>
	<head>
		<title>Schedule Administration || Appt! Personal Scheduler</title>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<style type="text/css">
<?php include($CONF['path_include'] . "/styles.css"); ?>
		</style>
		<script language="JavaScript">
		<!--
			function confirm_del($url)
			{
				var return_value = confirm('*** WARNING ***\n\nYou are about to remove this event.\n\nYour information will be lost.\n\nContinue?') ;
				if ( return_value == true ) { window.location = $url; }
			}
		-->
		</script>
	</head>
<body bgcolor="#ffffff">



<?php



//begin outer table structure
echo "<table align='center' border=\"0\" cellpadding=\"4\" cellspacing=\"4\" width=\"528\">
        <tr>
          <td>
            <table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"311\" bgcolor=\"black\">
              <tr>
                <td bgcolor=\"white\" valign=\"middle\" align=\"center\"><b>$daylong, $monthlong $today, $year</b></td>
              </tr>
            </table>
          </td>
          <td valign=\"middle\" align=\"center\">
            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
              <tr>
                <td valign=\"middle\" align=\"center\"><a href=\"" . $CONF['url_base'] . "/admin/admin.php?year=$last_year&today=$today&month=$month\" onmouseover=\"document.calb2.src='" . $CONF['url_images'] . "/ltab2over.gif'\" onmouseout=\"document.calb2.src='" . $CONF['url_images'] . "/ltab2.gif'\"><img src=\"" . $CONF['url_images'] . "/ltab2.gif\" border=\"0\" name=\"calb2\"></a></td><td>&nbsp;</td>
                <td valign=\"middle\" align=\"center\">
                  <table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"180\" bgcolor=\"black\">
                    <tr>
                      <td bgcolor=\"white\" valign=\"middle\" align=\"center\"><b>$year</b></td>
                    </tr>
                  </table>
                </td>
                <td>&nbsp;</td><td valign=\"middle\" align=\"center\"><a href=\"" . $CONF['url_base'] . "/admin/admin.php?year=$next_year&today=$today&month=$month\" onmouseover=\"document.calb1.src='" . $CONF['url_images'] . "/rtab2over.gif'\" onmouseout=\"document.calb1.src='" . $CONF['url_images'] . "/rtab2.gif'\"><img src=\"" . $CONF['url_images'] . "/rtab2.gif\" border=\"0\" name=\"calb1\"></a></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td valign=\"top\">

              <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"445\">
              <tr>
                <td class=\"cellbg\" valign=\"top\">";

// Load and display day title and content in fields
$sql_date = mktime(0, 0, 0, $month, $today, $year);
$sqlQuery = "SELECT ca_title, ca_text, ca_num ";
$sqlQuery .= "FROM calendar ";
$sqlQuery .= "WHERE ca_date = '$sql_date'";

if ( $sqlExec = QueryDB($CONF['dbConn'], $sqlQuery) )
{
	if ($sqlExec)
	   $nr = pg_num_rows($sqlExec);
	else
	   $nr = 0;

	if ( $nr > 0 && $data = pg_fetch_row($sqlExec, 0) )
	{
		$EVENT['title'] = $data[0];
		$EVENT['event']	= stripslashes($data[1]);
		$EVENT['html'] = 1;
		$EVENT['date'] = $sql_date;
		$EVENT['id'] = $data[2];
	}
}

if ( isset($EVENT['html']) && ($EVENT['html'] == 1) )
{
	$Ychecked = " checked";
	$Nchecked = "";
}
else
{
	$Ychecked = "";
	$Nchecked = " checked";
}

echo '<form name="post" action="post.php" method="post">
      <input type="hidden" name="year" value="' . $FORM['year'] . '">
      <input type="hidden" name="month" value="' . $FORM['month'] . '">
      <input type="hidden" name="today" value="' . $FORM['today'] . '">';
echo '<table cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td width="100%" colspan="2">';

echo 'HTML anzeigen? Nein<input type="radio" value="0" name="html" ' . $Nchecked . '> Ja<input type="radio" value="1" name="html" ' . $Ychecked . '><br /><br />
      Titel des Eintrags<br /><input type="text" name="day_title" value="' . $EVENT['title'] . '" size="40"><br />
      <br />
      Event Info<br /><textarea name="day_event" cols="40" rows="14">' . $EVENT['event'] . '</textarea>
      <br /><br />';
echo '</td></tr>';
echo '<tr><td width="50%" align="center">';
echo '<input type="image" src="' . $CONF['url_images'] . '/addevent.gif">';
echo '</td><td width="50%" align="center">';
echo "<a href=\"javascript:void(null)\" onClick=\"confirm_del('post.php?year=" . $FORM['year'] . "&month=" . $FORM['month'] . "&today=" . $FORM['today'] . "&del=1'); return false\"><img src=\"" . $CONF['url_images'] . "/delevent.gif\" border=\"0\"></a>\n";
echo '</td></tr>';
echo '<tr><td width="100%" align="center" colspan="2">';
echo "<br><center>";
echo "<a href='http://www.inconceivable.org/projects/appt'><font size='-2'>Powered by Appt! " . $CONF['__version'] . "</font></a>";
echo '<br />';
echo '<a href="../appt.php?year=' . $FORM['year'] . '&month=' . $FORM['month'] . '&today=' . $FORM['today'] . '" style="font-size:10px;">MAIN</a>';
echo "</center>";
echo '</td></tr>';
echo '</table>';
echo '</form>';

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

          <td valign=\"top\">

  <table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"black\" width=\"250\">
      <tr>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=1';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=1\" class=\"normal\">Jan</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=2';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=2\" class=\"normal\">Feb</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=3';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=3\" class=\"normal\">M&auml;r</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=4';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=4\" class=\"normal\">Apr</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=5';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=5\" class=\"normal\">Mai</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=6';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=6\" class=\"normal\">Jun</a> </td>
      </tr>
      <tr>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=7';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=7\" class=\"normal\">Jul</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=8';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=8\" class=\"normal\">Aug</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=9';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=9\" class=\"normal\">Sep</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=10';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=10\" class=\"normal\">Okt</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=11';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=11\" class=\"normal\">Nov</a> </td>
        <td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=1&month=12';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=12\" class=\"normal\">Dez</a> </td>
      </tr>
    </table><br />\n";


//display name of month
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"black\" width=\"250\">\n<tr>\n";
echo "<td class=\"cellbg\" colspan=\"7\" valign=\"middle\" align=\"center\"><font class=\"regheading\"><b>" . date("F",mktime(1,1,1,$month,1,$year)) . "</b></font>\n</td>\n";
echo "</tr>\n<tr>\n";


// Display day names
foreach($alldays as $value) {
  echo "<td class=\"cellbg\" valign=\"middle\" align=\"center\" width=\"10%\"><font class=\"normaltext\"><b>$value</b></font></td>\n";
}
echo "</tr>\n<tr>\n";


// Display blank days as nbsp's
for ($i = 0; $i < $dayone; $i++) {
  echo "<td class=\"cellbg\" valign=\"middle\" align=\"center\"><font class=\"normaltext\">&nbsp;</font></td>\n";
}


// Display days
for ($zz = 1; $zz <= $numdays; $zz++) {
  if ($i >= 7) {  print("</tr>\n<tr>\n"); $i=0; }
  //check current day for an event
  $result_found = 0;
  if ($zz == $today) { //mark todays cell regardless
    echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=$zz&month=$month';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='celltoday'\" class=\"celltoday\"><a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=$zz&month=$month\" class=\"today\">$zz</a></td>\n";
    $result_found = 1;
  }
  if ($result_found != 1) {//search for event on this day and mark cell if title not empty
    $sql_currentday = mktime(0, 0, 0, $month, $zz, $year);
    $eventQuery = "SELECT ca_title ";
    $eventQuery .= "FROM calendar ";
    $eventQuery .= "WHERE ca_date = '$sql_currentday'";

    $eventExec = QueryDB($CONF['dbConn'], $eventQuery);
    $nr = pg_num_rows($eventExec);
    $j = 0;

    while($j < $nr) {
       $data = pg_fetch_row($eventExec, $j);
       $row['title'] = $data[0];

      if (strlen($row["title"]) > 0)
      {
        echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=$zz&month=$month';\"  onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellevent'\" class=\"cellevent\"><a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=$zz&month=$month\" class=\"normal\">$zz</a></td>\n";
        $result_found = 1;
      }

      $j++;
    }
  }

  if ($result_found != 1) {//show default cell style for day
    echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=$zz&month=$month';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"><a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=$zz&month=$month\" class=\"normal\">$zz</a></td>\n";
  }

  $i++; $result_found = 0;
}

$create_emptys = 7 - (($dayone + $numdays) % 7);
if ($create_emptys == 7) { $create_emptys = 0; }

//display blank remaining cells
if ($create_emptys != 0) {
  echo "<td class=\"cellbg\" valign=\"middle\" align=\"center\" colspan=\"$create_emptys\"><font class=\"normaltext\">&nbsp;</font></td>\n";
}

echo "</tr>\n";
echo "</table><br />\n";
//add weekly glance here if needed
echo "<center><a href=\"".$_SERVER['PHP_SELF']."\" class=\"normal\">Jump to Today</a></center>";



//end outer table
echo "</td>
        </tr>
      </table>\n";

?>

	</body>
</html>
Return current item: TheoPlan