[ PHPXref.com ] [ Generated: Sun Jul 20 19:57:02 2008 ] [ PHP Timeclock 1.02 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> leftmain.php (source)

   1  <?php
   2  
   3  include  'config.inc.php';
   4  
   5  $self = $_SERVER['PHP_SELF'];
   6  $request = $_SERVER['REQUEST_METHOD'];
   7  
   8  // set cookie if 'Remember Me?' checkbox is checked, or reset cookie if 'Reset Cookie?' is checked //
   9  
  10  if ($request == 'POST'){
  11      @$remember_me = $_POST['remember_me'];
  12      @$reset_cookie = $_POST['reset_cookie'];
  13      @$fullname = stripslashes($_POST['left_fullname']);
  14      @$displayname = stripslashes($_POST['left_displayname']);
  15      if ((isset($remember_me)) && ($remember_me != '1')) {echo "Something is fishy here.\n"; exit;}
  16      if ((isset($reset_cookie)) && ($reset_cookie != '1')) {echo "Something is fishy here.\n"; exit;}
  17  
  18      // begin post validation //
  19  
  20      if ($show_display_name == "yes") {
  21  
  22          if (isset($displayname)) {
  23              $displayname = addslashes($displayname);
  24              $query = "select displayname from ".$db_prefix."employees where displayname = '".$displayname."'";
  25              $emp_name_result = mysql_query($query);
  26  
  27              while ($row = mysql_fetch_array($emp_name_result)) {
  28                  $tmp_displayname = "".$row['displayname']."";
  29              }
  30              if ((!isset($tmp_displayname)) && (!empty($displayname))) {echo "Username is not in the database.\n"; exit;}
  31              $displayname = stripslashes($displayname);
  32          }
  33  
  34      } 
  35  
  36      elseif ($show_display_name == "no") {
  37  
  38          if (isset($fullname)) {
  39              $fullname = addslashes($fullname);
  40              $query = "select empfullname from ".$db_prefix."employees where empfullname = '".$fullname."'";
  41              $emp_name_result = mysql_query($query);
  42  
  43              while ($row = mysql_fetch_array($emp_name_result)) {
  44                  $tmp_empfullname = "".$row['empfullname']."";
  45              }
  46              if ((!isset($tmp_empfullname)) && (!empty($fullname))) {echo "Username is not in the database.\n"; exit;}
  47              $fullname = stripslashes($fullname);
  48          }
  49  
  50      }
  51  
  52      // end post validation //
  53  
  54      if (isset($remember_me)) {
  55  
  56          if ($show_display_name == "yes") {
  57              setcookie("remember_me", stripslashes($displayname), time() + (60 * 60 * 24 * 365 * 2));
  58          } 
  59  
  60          elseif ($show_display_name == "no") {
  61              setcookie("remember_me", stripslashes($fullname), time() + (60 * 60 * 24* 365 * 2));
  62          }
  63  
  64      } 
  65  
  66      elseif (isset($reset_cookie)) {
  67          setcookie("remember_me", "", time() - 3600);
  68      }
  69  
  70      ob_end_flush();
  71  } 
  72  
  73  if ($display_weather == 'yes') {
  74  
  75      include  'phpweather.php';
  76      $metar = get_metar($metar);
  77      $data = process_metar($metar);
  78      $mph = "mph";
  79  
  80      // weather info //
  81  
  82      if (!isset($data['temp_f'])) {$temp = '';} else {$temp = $data['temp_f'];}
  83      if (!isset($data['windchill_f'])) {$windchill = '';} else {$windchill = $data['windchill_f'];}
  84      if (!isset($data['wind_dir_text_short'])) {$wind_dir = '';} else {$wind_dir = $data['wind_dir_text_short'];}
  85      if (!isset($data['wind_miles_per_hour'])) {$wind = '';} else {$wind = round($data['wind_miles_per_hour']);}
  86      if ($wind == 0) {$wind_dir = 'None'; $mph = ''; $wind = '';} else {$wind_dir = $wind_dir;}
  87      if (!isset($data['visibility_miles'])) {$visibility = '';} else {$visibility = $data['visibility_miles'];}
  88      if (!isset($data['rel_humidity'])) {$humidity = 'None';} else {$humidity = round($data['rel_humidity'], 0);}
  89      if (!isset($data['time'])) {$time = '';} else {$time = date($timefmt, $data['time']);}
  90      if (!isset($data['cloud_layer1_condition'])) {$cloud_cover = '';} else {$cloud_cover = $data['cloud_layer1_condition'];}
  91      if (($temp <> '') && ($temp >= '70') && ($humidity <> '')) {
  92          $heatindex = number_format(-42.379 + (2.04901523 * $temp) + (10.1433312 * $humidity) - (0.22475541 * $temp * $humidity)
  93                                     - (0.00683783 * ($temp * $temp)) - (0.05481717 * ($humidity * $humidity))
  94                                     + (0.00122874 * ($temp * $temp) * $humidity) + (0.00085282 * $temp * ($humidity * $humidity))
  95                                     - (0.00000199 * ($temp * $temp) * ($humidity * $humidity)));
  96      }
  97      if ((isset($heatindex)) || ($windchill <> '')) {
  98          if (!isset($heatindex)) {
  99              $feelslike = $windchill;
 100          } else {
 101              $feelslike = $heatindex;
 102          }
 103      } else {
 104          $feelslike = $temp;
 105      }
 106  }
 107  
 108  echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n";
 109  echo "  <tr valign=top>\n";
 110  echo "    <td class=left_main width=170 align=left scope=col>\n";
 111  echo "      <table class=hide width=100% border=0 cellpadding=1 cellspacing=0>\n";
 112  
 113  // display links in top left of each page //
 114  
 115  if ($links == "none") {
 116      echo "        <tr></tr>\n";
 117  } else {
 118      echo "        <tr><td class=left_rows height=7 align=left valign=middle></td></tr>\n";
 119  
 120      for ($x=0; $x<count($display_links); $x++) {
 121          echo "        <tr><td class=left_rows height=18 align=left valign=middle><a class=admin_headings href='$links[$x]'>$display_links[$x]</a></td>
 122                        </tr>\n";
 123      }
 124  
 125  }
 126  
 127  // display form to submit signin/signout information //
 128  
 129  echo "        <form name='timeclock' action='$self' method='post'>\n";
 130  
 131  if ($links == "none") {
 132      echo "        <tr><td height=7></td></tr>\n";
 133  } else {
 134      echo "        <tr><td height=20></td></tr>\n";
 135  }
 136  
 137  echo "        <tr><td class=title_underline height=4 align=left valign=middle style='padding-left:10px;'>Please sign in below:</td></tr>\n";
 138  echo "        <tr><td height=7></td></tr>\n";
 139  echo "        <tr><td height=4 align=left valign=middle class=misc_items>Name:</td></tr>\n";
 140  echo "        <tr><td height=4 align=left valign=middle class=misc_items>\n";
 141  
 142  // query to populate dropdown with employee names //
 143  
 144  if ($show_display_name == "yes") {
 145  
 146      $query = "select displayname from ".$db_prefix."employees where disabled <> '1'  and empfullname <> 'admin' order by displayname";
 147      $emp_name_result = mysql_query($query);
 148      echo "              <select name='left_displayname' tabindex=1>\n";
 149      echo "              <option value =''>...</option>\n";
 150  
 151      while ($row = mysql_fetch_array($emp_name_result)) {
 152  
 153          $abc = stripslashes("".$row['displayname']."");
 154  
 155          if ((isset($_COOKIE['remember_me'])) && (stripslashes($_COOKIE['remember_me']) == $abc)) {
 156              echo "              <option selected>$abc</option>\n";
 157          } else {
 158              echo "              <option>$abc</option>\n";
 159          }
 160  
 161      }
 162  
 163      echo "              </select></td></tr>\n";
 164      mysql_free_result($emp_name_result);
 165      echo "        <tr><td height=7></td></tr>\n";
 166  
 167  } else {
 168  
 169      $query = "select empfullname from ".$db_prefix."employees where disabled <> '1'  and empfullname <> 'admin' order by empfullname";
 170      $emp_name_result = mysql_query($query);
 171      echo "              <select name='left_fullname' tabindex=1>\n";
 172      echo "              <option value =''>...</option>\n";
 173  
 174      while ($row = mysql_fetch_array($emp_name_result)) {
 175  
 176          $def = stripslashes("".$row['empfullname']."");
 177          if ((isset($_COOKIE['remember_me'])) && (stripslashes($_COOKIE['remember_me']) == $def)) {
 178              echo "              <option selected>$def</option>\n";
 179          } else {
 180              echo "              <option>$def</option>\n";
 181          }
 182  
 183      }
 184  
 185      echo "              </select></td></tr>\n";
 186      mysql_free_result($emp_name_result);
 187      echo "        <tr><td height=7></td></tr>\n";
 188  }
 189  
 190  // determine whether to use encrypted passwords or not //
 191  
 192  if ($use_passwd == "yes") {    
 193      echo "        <tr><td height=4 align=left valign=middle class=misc_items>Password:</td></tr>\n";
 194      echo "        <tr><td height=4 align=left valign=middle class=misc_items>";
 195      echo          "<input type='password' name='employee_passwd' maxlength='25' size='17' tabindex=2></td></tr>\n";
 196      echo "        <tr><td height=7></td></tr>\n";
 197  }
 198  
 199  echo "        <tr><td height=4 align=left valign=middle class=misc_items>In/Out:</td></tr>\n";
 200  echo "        <tr><td height=4 align=left valign=middle class=misc_items>\n";
 201  
 202  // query to populate dropdown with punchlist items //
 203  
 204  $query = "select punchitems from ".$db_prefix."punchlist";
 205  $punchlist_result = mysql_query($query);
 206  
 207  echo "              <select name='left_inout' tabindex=3>\n";
 208  echo "              <option value =''>...</option>\n";
 209  
 210  while ($row = mysql_fetch_array($punchlist_result)) {
 211      echo "              <option>".$row['punchitems']."</option>\n";
 212  }
 213  
 214  echo "              </select></td></tr>\n";
 215  mysql_free_result( $punchlist_result );
 216  
 217  echo "        <tr><td height=7></td></tr>\n";
 218  echo "        <tr><td height=4 align=left valign=middle class=misc_items>Notes:</td></tr>\n";
 219  echo "        <tr><td height=4 align=left valign=middle class=misc_items>";  
 220  echo          "<input type='text' name='left_notes' maxlength='250' size='17' tabindex=4></td></tr>\n";
 221  
 222  if (!isset($_COOKIE['remember_me'])) {
 223      echo "        <tr><td width=100%><table width=100% border=0 cellpadding=0 cellspacing=0>
 224                    <tr><td nowrap height=4 align=left valign=middle class=misc_items width=10%>Remember&nbsp;Me?</td><td width=90% align=left 
 225                      class=misc_items style='padding-left:0px;padding-right:0px;' tabindex=5><input type='checkbox' name='remember_me' value='1'></td></tr>
 226                      </table></td><tr>\n";
 227  } 
 228  
 229  elseif (isset($_COOKIE['remember_me'])) {
 230      echo "        <tr><td width=100%><table width=100% border=0 cellpadding=0 cellspacing=0>
 231                    <tr><td nowrap height=4 align=left valign=middle class=misc_items width=10%>Reset&nbsp;Cookie?</td><td width=90% align=left 
 232                      class=misc_items style='padding-left:0px;padding-right:0px;' tabindex=5><input type='checkbox' name='reset_cookie' value='1'></td></tr>
 233                      </table></td><tr>\n";
 234  }
 235  
 236  echo "        <tr><td height=7></td></tr>\n";
 237  echo "        <tr><td height=4 align=left valign=middle class=misc_items><input type='submit' name='submit_button' value='Submit' align='center' 
 238                  tabindex=6></td></tr></form>\n";
 239  
 240  if ($display_weather == "yes") {
 241      echo "        <tr><td height=25 align=left valign=bottom class=misc_items><font color='00589C'><b><u>Weather Conditions:</u></b></font></td></tr>\n";
 242      echo "        <tr><td height=7></td></tr>\n";
 243      echo "        <tr><td align=left valign=middle class=misc_items><b>$city</b></td></tr>\n";
 244      echo "        <tr><td height=4></td></tr>\n";
 245      echo "        <tr><td align=left valign=middle class=misc_items>Currently: $temp&#176;</td></tr>\n";
 246      echo "        <tr><td height=4></td></tr>\n";
 247      echo "        <tr><td align=left valign=middle class=misc_items>Feels Like: $feelslike&#176;</td></tr>\n";
 248      echo "        <tr><td height=4></td></tr>\n";
 249      echo "        <tr><td align=left valign=middle class=misc_items>Skies: $cloud_cover</td></tr>\n";
 250      echo "        <tr><td height=4></td></tr>\n";
 251      echo "        <tr><td align=left valign=middle class=misc_items>Wind: $wind_dir $wind$mph</td></tr>\n";
 252      echo "        <tr><td height=4></td></tr>\n";
 253  
 254      if ($humidity == 'None') {
 255          echo "        <tr><td align=left valign=middle class=misc_items>Humidity: $humidity</td></tr>\n";
 256      } else {
 257          echo "        <tr><td align=left valign=middle class=misc_items>Humidity: $humidity%</td></tr>\n";
 258      }
 259  
 260      echo "        <tr><td height=4></td></tr>\n";
 261      echo "        <tr><td align=left valign=middle class=misc_items>Visibility: $visibility miles</td></tr>\n";
 262      echo "        <tr><td height=4></td></tr>\n";
 263      echo "        <tr><td align=left valign=middle class=misc_items><font color='FF0000'>Last Updated: $time</font></td></tr>\n";
 264  }
 265  
 266  echo "        <tr><td height=90%></td></tr>\n";
 267  echo "      </table></td>\n";
 268  
 269  if ($request == 'POST') {
 270  
 271      // signin/signout data passed over from timeclock.php //
 272  
 273      $inout = $_POST['left_inout'];
 274      $notes = ereg_replace("[^[:alnum:] \,\.\?-]","",strtolower($_POST['left_notes']));
 275  
 276      // begin post validation //
 277  
 278      if ($use_passwd == "yes") {
 279          $employee_passwd = crypt($_POST['employee_passwd'], 'xy');
 280      }
 281  
 282      $query = "select punchitems from ".$db_prefix."punchlist";
 283      $punchlist_result = mysql_query($query);
 284  
 285      while ($row = mysql_fetch_array($punchlist_result)) {
 286          $tmp_inout = "".$row['punchitems']."";
 287      }
 288  
 289      if (!isset($tmp_inout)) {echo "In/Out Status is not in the database.\n"; exit;}
 290  
 291      // end post validation //
 292  
 293      if ($show_display_name == "yes") {
 294  
 295          if (!$displayname && !$inout) {
 296              echo "    <td align=left class=right_main scope=col>\n";
 297              echo "      <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
 298              echo "        <tr class=right_main_text>\n";
 299              echo "          <td valign=top>\n";
 300              echo "<br />\n";
 301              echo "You have not chosen a username or a status. Please try again.\n";
 302              include  'footer.php';
 303              exit;
 304          }
 305  
 306          if (!$displayname) {
 307              echo "    <td align=left class=right_main scope=col>\n";
 308              echo "      <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
 309              echo "        <tr class=right_main_text>\n";
 310              echo "          <td valign=top>\n";
 311              echo "<br />\n";
 312              echo "You have not chosen a username. Please try again.\n";
 313              include  'footer.php';
 314              exit;
 315          }
 316  
 317      } 
 318      
 319      elseif ($show_display_name == "no") {
 320  
 321          if (!$fullname && !$inout) {
 322              echo "    <td align=left class=right_main scope=col>\n";
 323              echo "      <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
 324              echo "        <tr class=right_main_text>\n";
 325              echo "          <td valign=top>\n";
 326              echo "<br />\n";
 327              echo "You have not chosen a username or a status. Please try again.\n";
 328              include  'footer.php';
 329              exit;
 330          }
 331  
 332          if (!$fullname) {
 333              echo "    <td align=left class=right_main scope=col>\n";
 334              echo "      <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
 335              echo "        <tr class=right_main_text>\n";
 336              echo "          <td valign=top>\n";
 337              echo "<br />\n";
 338              echo "You have not chosen a username. Please try again.\n";
 339              include  'footer.php';
 340              exit;
 341          }
 342  
 343      }
 344  
 345      if (!$inout) {
 346          echo "    <td align=left class=right_main scope=col>\n";
 347          echo "      <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
 348          echo "        <tr class=right_main_text>\n";
 349          echo "          <td valign=top>\n";
 350          echo "<br />\n";
 351          echo "You have not chosen a status. Please try again.\n";
 352          include  'footer.php';
 353          exit;
 354      }
 355  
 356      @$fullname = addslashes($fullname);
 357      @$displayname = addslashes($displayname);
 358  
 359      // configure timestamp to insert/update //
 360  
 361      $hour = gmdate('H');
 362      $min = gmdate('i');
 363      $sec = gmdate('s');
 364      $month = gmdate('m');
 365      $day = gmdate('d');
 366      $year = gmdate('Y');
 367      $tz_stamp = mktime ($hour, $min, $sec, $month, $day, $year);
 368  
 369      if ($use_passwd == "no") {
 370  
 371          if ($show_display_name == "yes") {
 372  
 373              $sel_query = "select empfullname from ".$db_prefix."employees where displayname = '".$displayname."'";
 374              $sel_result = mysql_query($sel_query);
 375  
 376              while ($row=mysql_fetch_array($sel_result)) {
 377                  $fullname = stripslashes("".$row["empfullname"]."");
 378                  $fullname = addslashes($fullname);
 379              }
 380          }
 381  
 382          if (strtolower($ip_logging) == "yes") {
 383              $query = "insert into ".$db_prefix."info (fullname, `inout`, timestamp, notes, ipaddress) values ('".$fullname."', '".$inout."', 
 384                        '".$tz_stamp."', '".$notes."', '".$connecting_ip."')";
 385          } else {
 386              $query = "insert into ".$db_prefix."info (fullname, `inout`, timestamp, notes) values ('".$fullname."', '".$inout."', '".$tz_stamp."', 
 387                        '".$notes."')";
 388          }
 389  
 390          $result = mysql_query($query);
 391  
 392          $update_query = "update ".$db_prefix."employees set tstamp = '".$tz_stamp."' where empfullname = '".$fullname."'";
 393          $other_result = mysql_query($update_query);
 394  
 395          echo "<head>\n";
 396          echo "<meta http-equiv='refresh' content=0;url=index.php>\n";
 397          echo "</head>\n";
 398  
 399      } else {
 400  
 401      if ($show_display_name == "yes") {
 402          $sel_query = "select empfullname, employee_passwd from ".$db_prefix."employees where displayname = '".$displayname."'";
 403          $sel_result = mysql_query($sel_query);
 404  
 405          while ($row=mysql_fetch_array($sel_result)) {
 406              $tmp_password = "".$row["employee_passwd"]."";
 407              $fullname = "".$row["empfullname"]."";
 408          }
 409  
 410          $fullname = stripslashes($fullname);
 411          $fullname = addslashes($fullname);
 412  
 413      } else {
 414  
 415          $sel_query = "select empfullname, employee_passwd from ".$db_prefix."employees where empfullname = '".$fullname."'";
 416          $sel_result = mysql_query($sel_query);
 417  
 418          while ($row=mysql_fetch_array($sel_result)) {
 419              $tmp_password = "".$row["employee_passwd"]."";
 420          }
 421  
 422      }
 423  
 424      if ($employee_passwd == $tmp_password) {
 425  
 426          if (strtolower($ip_logging) == "yes") {
 427              $query = "insert into ".$db_prefix."info (fullname, `inout`, timestamp, notes, ipaddress) values ('".$fullname."', '".$inout."', 
 428                        '".$tz_stamp."', '".$notes."', '".$connecting_ip."')";
 429          } else {
 430              $query = "insert into ".$db_prefix."info (fullname, `inout`, timestamp, notes) values ('".$fullname."', '".$inout."', '".$tz_stamp."', 
 431                        '".$notes."')";
 432          }
 433  
 434          $result = mysql_query($query);
 435   
 436          $update_query = "update ".$db_prefix."employees set tstamp = '".$tz_stamp."' where empfullname = '".$fullname."'";
 437          $other_result = mysql_query($update_query);
 438  
 439          echo "<head>\n";
 440          echo "<meta http-equiv='refresh' content=0;url=index.php>\n";
 441          echo "</head>\n";
 442  
 443      } else {
 444  
 445          echo "    <td align=left class=right_main scope=col>\n";
 446          echo "      <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n";
 447          echo "        <tr class=right_main_text>\n";
 448          echo "          <td valign=top>\n";
 449          echo "<br />\n";
 450  
 451          if ($show_display_name == "yes") {
 452              $strip_fullname = stripslashes($displayname);
 453          } else {
 454              $strip_fullname = stripslashes($fullname);
 455          }
 456  
 457          echo "You have entered the wrong password for $strip_fullname. Please try again.";
 458          include  'footer.php'; exit;
 459      }
 460  
 461  }
 462  }
 463  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]