C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$R30CG93\tcpro\daynote.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php
/**
 * daynote.php
 * 
 * Displays the daynote dialog
 * 
 * @package TeamCalPro
 * @version 3.3.001 
 * @author George Lewe
 * @copyright Copyright (c) 2004-2010 by George Lewe
 * @link http://www.lewe.com
 * @license http://www.lewe.com/tcpro/doc/license.txt Extended GNU Public License
 */
    
//echo "<script type=\"text/javascript\">alert(\"Debug: \");</script>";
 
/**
 * Set parent flag to control access to child scripts 
 */
define'_VALID_TCPRO');

/**
 * Includes 
 */
require ("config.tcpro.php");
require_once (
"includes/functions.tcpro.php");
getOptions();
if (
strlen($CONF['options']['lang'])) require ("includes/lang/" $CONF['options']['lang'] . ".tcpro.php");
else                                  require (
"includes/lang/english.tcpro.php");

require_once( 
"includes/tcconfig.class.php" );
require_once( 
"includes/tcdaynote.class.php" );
require_once( 
"includes/tclogin.class.php" );
require_once( 
"includes/tclog.class.php" );
require_once( 
"includes/tcuser.class.php" );

$C = new tcConfig;
$L = new tcLogin;
$LOG = new tcLog;
$N = new tcDaynote;
$U = new tcUser;
 
$error false;
$event NULL;

if (isset (
$_REQUEST['region'])) $region $_REQUEST['region']; else $region "default";
 
/**
 * Let's see if we have a note for this day already
 */
$daynote_exists false;
if ( 
strtolower($_REQUEST['daynotefor'])=="all" ) {
   
/**
    * Check if authorized
    */
   
if ( !checkAuth("daynoteMonth") ) {
      
$error=true;
      
$err_short=$LANG['err_not_authorized_short'];
      
$err_long=$LANG['err_not_authorized_long'];
      
$err_module="daynote.php";
   }
   
/**
    * Look for a general daynote for this day
    */
   
if ( $N->findByDay($_REQUEST['date'],"all",$region) ) $daynote_exists true;
   
} else {
   if ( !
checkAuth("daynoteUser",$_REQUEST['daynotefor']) ) {
      
$error=true;
      
$err_short=$LANG['err_not_authorized_short'];
      
$err_long=$LANG['err_not_authorized_long'];
      
$err_module="daynote.php";
   }
   
/**
    * Look for a user-specific daynote for this day And once you're at it get
    * the users full name.
    */
   
if ( $N->findByDay($_REQUEST['date'],$_REQUEST['daynotefor'],$region) ) $daynote_exists true;
   if ( !
$U->findByName($_REQUEST['daynotefor']) ) {
      
$event="warning";
      
$errmsg  $LANG['err_input_caption'];
      
$errmsg .= $LANG['err_input_daynote_nouser'];
      
$errmsg .= $LANG['err_input_daynote_date'].$_REQUEST['date']."\\n";
      
$errmsg .= $LANG['err_input_daynote_username'].$_REQUEST['daynotefor']."\\n";
   } else {
      
$daynote_user $U->firstname." ".$U->lastname;
   }
}

/**
 * Process submitted form
 */
if (isset($_POST['btn_save'])) {
   if ( 
strlen($_POST['daynote']) ) {
      
$N->daynote str_replace("\r\n","<br>",trim($_POST['daynote']));
      
$N->update();
      
/**
       * Log this event
       */
      
$LOG->log("logDaynote",$L->checkLogin(),"Daynote updated: ".$_REQUEST['date']." - ".$_REQUEST['daynotefor']." - ".$region." : ".substr($N->daynote,0,20)."...");
   } else {
      
$event="warning";
      
$errmsg  $LANG['err_input_caption'];
      
$errmsg .= $LANG['err_input_daynote_save'];
   }
}
else if (isset(
$_POST['btn_create'])) {
   if ( 
strlen($_POST['daynote']) ) {
      
$N->yyyymmdd $_REQUEST['date'];
      
$N->daynote str_replace("\r\n","<br>",trim($_POST['daynote']));
      
$N->username $_REQUEST['daynotefor'];
      
$N->region $region;
      
$N->create();
      
/**
       * Log this event
       */
      
$LOG->log("logDaynote",$L->checkLogin(),"Daynote created: ".$_REQUEST['date']." - ".$_REQUEST['daynotefor']." - ".$region." : ".substr($N->daynote,0,20)."...");
      
$daynote_exists=true;
   } else {
      
$event="warning";
      
$errmsg  $LANG['err_input_caption'];
      
$errmsg .= $LANG['err_input_daynote_create'];
   }
}
else if (isset(
$_POST['btn_delete'])) {
   if ( 
$N->findByDay($_REQUEST['date'],$_REQUEST['daynotefor'],$region) ) {
      
$N->deleteByDay($_REQUEST['date'],$_REQUEST['daynotefor'],$region);
      
/**
       * Log this event
       */
      
$LOG->log("logDaynote",$L->checkLogin(),"Daynote deleted: ".$_REQUEST['date']." - ".$_REQUEST['daynotefor']." - ".$region." : ".substr($N->daynote,0,20)."...");
      
$daynote_exists=false;
   }
}
 
/**
 * Include HTML header
 */
require( "includes/header.html.inc.php" );

/**
 * Display error message or the page
 */
if ($error) {
   include (
"error.php");
}else{ 
?> 

<body>
   <form name="message" method="POST" action="<?=$_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']."&amp;date=".$_REQUEST['date']."&amp;daynotefor=".$_REQUEST['daynotefor']."&amp;region=".$region."&amp;datestring=".$_REQUEST['datestring']?>">
   <table class="dlg">
      <tr>
         <td class="dlg-header" colspan="3">
            <?php
            $title
=$LANG['daynote_edit_title'].$_REQUEST['datestring']." (".$LANG['month_region'].": ".$region.")"
            if ( 
$_REQUEST['daynotefor']!="all" $title .= " ".$LANG['daynote_edit_title_for']." ".$daynote_user;
            
printDialogTop($title,"daynote_dialog.html","ico_daynote.png");
            
?>
         </td>
      </tr>
   </table>
   <table class="dlg">
      <tr>
         <td class="dlg-body">
            <table class="dlg-frame">
               <tr>
                  <td class="dlg-body"><strong><?=$LANG['daynote_edit_msg_caption']?></strong><br>
                  <?=$LANG['daynote_edit_msg_hint']?></td>
               </tr>
               <tr>
                  <td class="dlg-body">
                     <textarea name="daynote" id="daynote" class="text" cols="50" rows="6">
<?php if ( $daynote_exists ) echo str_replace("<br>","\r\n",trim($N->daynote)); else echo str_replace("<br>","\r\n",$LANG['daynote_edit_msg']); ?>
                     </textarea>
                     <br />
                  </td>
               </tr>
            </table>
         </td>
        </tr>
        <tr>
           <td class="dlg-menu">
              <?php
              
if ($daynote_exists) { ?>
               
                  <input name="btn_save" type="submit" class="button" value="<?=$LANG['btn_save']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';">
                  <input name="btn_delete" type="submit" class="button" value="<?=$LANG['btn_delete']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';">
              <?php } else { ?>
                  <input name="btn_create" type="submit" class="button" value="<?=$LANG['btn_create']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';">
              <?php ?>
              <input name="btn_help" type="button" class="button" onclick="javascript:this.blur(); openPopup('help/<?=$CONF['options']['helplang']?>/html/index.html?daynote_dialog.html','help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,titlebar=0,resizable=0,dependent=1,width=740,height=500');" value="<?=$LANG['btn_help']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';">
              <input name="btn_close" type="button" class="button" onclick="javascript:window.close();" value="<?=$LANG['btn_close']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';">
              <input name="btn_done" type="button" class="button" onclick="javascript:closeme();" value="<?=$LANG['btn_done']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';">
           </td>
        </tr>
     </table>
     </form>
     <br />

<?php
   
switch ($event) {
      case 
"created": echo ("<script type=\"text/javascript\">alert(\"" $LANG['daynote_edit_event_created'] . "\")</script>"); break;
      case 
"saved":   echo ("<script type=\"text/javascript\">alert(\"" $LANG['daynote_edit_event_saved'] . "\")</script>"); break;
      case 
"deleted": echo ("<script type=\"text/javascript\">alert(\"" $LANG['daynote_edit_event_deleted'] . "\")</script>"); break;
      case 
"warning": echo ("<script type=\"text/javascript\">alert(\"" $warnmsg "\")</script>"); break;
      default: break;
   }
}
require( 
"includes/footer.html.inc.php" );
?>