C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\heimam\tcpro\regions.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
/**
 * regions.php
 * 
 * Displays the regions administration page
 * 
 * @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/tclog.class.php" );
require_once(
"includes/tclogin.class.php" );
require_once(
"includes/tcregion.class.php" );
require_once(
"includes/tcuser.class.php" );

$C = new tcConfig;
$L = new tcLogin
$LOG = new tcLog
$R  = new tcRegion;
$U  = new tcUser;

$error false;

/**
 * Check if allowed 
 */
if (!checkAuth("admin")) {
   
// Not authorized. Get outta here
   
jsReload("index.php");
}

/**
 * Get current month and year
 */
$today     getdate();
$monthtoday $CONF['monthnames'][$today['mon']];   // Numeric representation of todays' month
$yeartoday  $today['year'];  // A full numeric representation of todays' year, 4 digits

/**
 * Add Region 
 */
if ( isset($_POST['btn_reg_add']) ) {
  
   if (
trim($_POST['reg_nameadd'])!='') {
      
$R->regionname=preg_replace("/[^A-Za-z0-9_]/i",'',trim($_POST['reg_nameadd']));
      
$R->description=htmlspecialchars($_POST['reg_descadd'],ENT_QUOTES);
      
$R->options=0x000000;
      if (
$_POST['chkHide']) $R->setOptions($CONF['R_HIDE']);
      
$R->create();
      
/**
       * Log this event
       */
      
$LOG->log("logRegion",$L->checkLogin(),"Region added: ".$R->regionname);
   }else{
      
$error true;
      
$errmsg  $LANG['err_input_caption'];
      
$errmsg .= $LANG['err_input_region_add'];
   }
  
/**
 * Update Region
 */
} else if ( isset($_POST['btn_reg_update']) ) {
         
   
// Drop old and save new value.
   
$R->deleteByName($_POST['reg_namehidden']);
   
$R->regionname=preg_replace("/[^a-z0-9]/i",'',$_POST['reg_name']);
   
$R->description=htmlspecialchars($_POST['reg_desc'],ENT_QUOTES);
   
$R->options=0x000000;
   if (
$_POST['chkHide']) $R->setOptions($CONF['R_HIDE']);
   
$R->create();
   
/**
    * Log this event
    */
   
$LOG->log("logRegion",$L->checkLogin(),"Region updated: ".$R->regionname);
     
/**
 * Delete Region 
 */
} else if ( isset($_POST['btn_reg_delete']) ) {
         
   
$R->deleteByName($_POST['reg_namehidden']);
   
/**
    * Log this event
    */
   
$LOG->log("logRegion",$L->checkLogin(),"Region deleted: ".$_POST['reg_namehidden']);
     
}

/**
 * Show HTML header
 * Use this file to adjust your meta tags and such
 */
require("includes/header.html.inc.php");

echo 
"<body>\r\n";
echo 
"<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\r\n";

/**
 * Show application header
 * This is the file to change in order to put different images at the top
 * of the main page.
 */
require("includes/header.application.inc.php");

/**
 * Show menu header
 * This is the file containing the TeamCal menu
 */
require("includes/menu.inc.php");

/**
 * Show error message
 * If any error occurred so far, show it now.
 */
if ($error)
   echo (
"<script type=\"text/javascript\">alert(\"" $errmsg "\")</script>");
?>
   <table width="100%">
      <tr>
         <td valign="top">
            
            <!--  REGIONS =========================================================== -->
            <table class="dlg" cellspacing="0">
               <tr>
                  <td class="dlg-header" colspan="3">
                     <?php printDialogTop($LANG['admin_region_title'],"manage_regions.html","ico_region.png"); ?>
                  </td>
               </tr>
            </table>
            <table class="dlg" cellspacing="0">
               <tr>
                  <td class="dlg-caption">
                     <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                           <td width="5%" style="text-align: left;">&nbsp;</td>
                           <td width="25%" style="text-align: left;">[<?=$LANG['column_shortname']?>]</td>
                           <td width="30%" style="text-align: left;">[<?=$LANG['column_description']?>]</td>
                           <td width="10%" style="text-align: left;">[<?=$LANG['column_hide']?>]</td>
                           <td width="30%" style="text-align: left;">[<?=$LANG['column_action']?>]</td>
                        </tr>
                     </table>
                  </td>
               </tr>
               <tr>
                  <td>
                     
                     <!-- Add new region -->
                     <form class="form" name="form-grp-add" method="POST" action="<?=$_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']?>">
                     <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                           <td class="dlg-row1" width="5%"><img src="themes/<?=$theme?>/img/ico_add.png" alt="Region" title="Region" align="absmiddle" style="padding-right: 2px;"></td>
                           <td class="dlg-row1" width="25%"><input name="reg_nameadd" size="16" type="text" class="text" id="reg_nameadd" value=""></td>
                           <td class="dlg-row1" width="30%"><input name="reg_descadd" size="34" type="text" class="text" id="reg_descadd" value=""></td>
                           <td class="dlg-row1" width="10%"><input name="chkHide" type="checkbox" value="chkHide"></td>
                           <td class="dlg-row1" width="30%"><input name="btn_reg_add" type="submit" class="button" value="<?=$LANG['btn_add']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"></td>
                        </tr>
                     </table>
                     </form>
                     <?php
                     $query  
"SELECT `regionname` FROM `".$R->table."` ORDER BY `regionname`;";
                     
$result $R->db->db_query($query);
                     
$i=1;
                     
$printrow=1;
                     echo 
"
                     
                     <!-- default -->
                     <form class=\"form\" name=\"form-grp-"
.$i."\" method=\"POST\" action=\"".$_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']."\">
                     <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
                        <tr>
                           <td class=\"dlg-row"
.$printrow."\" width=\"5%\"><img src=\"themes/".$theme."/img/ico_region.png\" alt=\"Region\" title=\"Region\" align=\"absmiddle\" style=\"padding-right: 2px;\"></td>
                           <td class=\"dlg-row"
.$printrow."\" width=\"25%\"><input name=\"reg_namehidden\" type=\"hidden\" class=\"text\" value=\"default\"><input name=\"reg_name\" size=\"16\" type=\"text\" class=\"text\" value=\"default\" DISABLED></td>
                           <td class=\"dlg-row"
.$printrow."\" width=\"30%\"><input name=\"reg_desc\" size=\"34\" type=\"text\" class=\"text\" value=\"Default Region\" DISABLED></td>
                           <td class=\"dlg-row"
.$printrow."\" width=\"10%\">&nbsp;</td>
                           <td class=\"dlg-row"
.$printrow."\" width=\"30%\">
                              <input name=\"btn_reg_edit\" type=\"submit\" class=\"button\" value=\""
.$LANG['btn_edit']."\" onmouseover=\"this.className='button-over';\" onmouseout=\"this.className='button';\" onclick=\"javascript:openPopup('editmonth.php?lang=".$CONF['options']['lang']."&amp;region=default&amp;Year=".$yeartoday."&amp;Month=".$monthtoday."','shop','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=no,dependent=1,width=960,height=300');\" >
                           </td>
                        </tr>
                     </table>
                     </form>
                     "
;
                     while ( 
$row $R->db->db_fetch_array($result,MYSQL_ASSOC) ){
                        
$R->findByName(stripslashes($row['regionname']));
                        if (
$R->regionname!="default") {
                           if (
$printrow==1$printrow=2; else $printrow=1;
                           echo 
"
                           
                           <!-- "
.$R->regionname." -->
                           <form class=\"form\" name=\"form-grp-"
.$i."\" method=\"POST\" action=\"".$_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']."\">
                           <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
                              <tr>
                                 <td class=\"dlg-row"
.$printrow."\" width=\"5%\"><img src=\"themes/".$theme."/img/ico_region.png\" alt=\"Region\" title=\"Region\" align=\"absmiddle\" style=\"padding-right: 2px;\"></td>
                                 <td class=\"dlg-row"
.$printrow."\" width=\"25%\"><input name=\"reg_namehidden\" type=\"hidden\" class=\"text\" value=\"".$R->regionname."\"><input name=\"reg_name\" size=\"16\" type=\"text\" class=\"text\" value=\"".$R->regionname."\"></td>
                                 <td class=\"dlg-row"
.$printrow."\" width=\"30%\"><input name=\"reg_desc\" size=\"34\" type=\"text\" class=\"text\" value=\"".$R->description."\"></td>
                                 <td class=\"dlg-row"
.$printrow."\" width=\"10%\"><input name=\"chkHide\" type=\"checkbox\" value=\"chkHide\" ".($R->checkOptions($CONF['R_HIDE'])?'CHECKED':'')."></td>
                                 <td class=\"dlg-row"
.$printrow."\" width=\"30%\">
                                    <input name=\"btn_reg_update\" type=\"submit\" class=\"button\" value=\""
.$LANG['btn_update']."\" onmouseover=\"this.className='button-over';\" onmouseout=\"this.className='button';\">&nbsp;
                                    <input name=\"btn_reg_delete\" type=\"submit\" class=\"button\" value=\""
.$LANG['btn_delete']."\" onmouseover=\"this.className='button-over';\" onmouseout=\"this.className='button';\" onclick=\"return confirmSubmit('".$LANG['eg_delete_confirm']."')\" >&nbsp;
                                    <input name=\"btn_reg_edit\" type=\"submit\" class=\"button\" value=\""
.$LANG['btn_edit']."\" onmouseover=\"this.className='button-over';\" onmouseout=\"this.className='button';\" onclick=\"javascript:openPopup('editmonth.php?lang=".$CONF['options']['lang']."&amp;region=".$R->regionname."&amp;Year=".$yeartoday."&amp;Month=".$monthtoday."','shop','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=no,dependent=1,width=960,height=300');\" >
                                 </td>
                              </tr>
                           </table>
                           </form>
                           "
;
                           
$i+=1;
                        }
                     } 
                     
?>
                  </td>
               </tr>
            </table>
            <br>

         </td>
      </tr>
   </table>
<?php
require("includes/footer.html.inc.php");
?>