Advertisement
tjromano

Functions

Aug 27th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.34 KB | None | 0 0
  1. <?php
  2.  
  3. //function to get the date
  4. function last_login()
  5. {
  6.     $date = gmdate("Y-m-d");
  7.     return $date;
  8. }
  9.  
  10. //function that sets the session variable
  11. function sess_vars($base_dir, $server, $dbusername, $dbpassword, $db_name, $table_name, $user, $pass)
  12. {
  13.  
  14.  
  15.     //make connection to dbase
  16.     $connection = @mysql_connect($server, $dbusername, $dbpassword)
  17.                 or die(mysql_error());
  18.                
  19.     $db = @mysql_select_db($db_name,$connection)
  20.                 or die(mysql_error());
  21.                
  22.     $sql = "SELECT * FROM $table_name WHERE username = '$user' and password = password('$pass')";
  23.  
  24.     $result = @mysql_query($sql, $connection) or die(mysql_error());
  25.  
  26.  
  27.     //get the number of rows in the result set
  28.     $num = mysql_num_rows($result);
  29.  
  30.     //set session variables if there is a match
  31.     if ($num != 0)
  32.     {
  33.         while ($sql = mysql_fetch_object($result))
  34.         {
  35.             $_SESSION[first_name]   = $sql -> firstname;
  36.             $_SESSION[last_name]    = $sql -> lastname;
  37.             $_SESSION[user_name]    = $sql -> username;      
  38.             $_SESSION[password]     = $sql -> password;
  39.             $_SESSION[group1]       = $sql -> group1;
  40.             $_SESSION[group2]       = $sql -> group2;
  41.             $_SESSION[group3]       = $sql -> group3;
  42.             $_SESSION[pchange]      = $sql -> pchange;  
  43.             $_SESSION[email]        = $sql -> email;
  44.             $_SESSION[redirect]     = $sql -> redirect;
  45.             $_SESSION[verified]     = $sql -> verified;
  46.             $_SESSION[last_login]   = $sql -> last_login;
  47.         }
  48.     }else{
  49.         $_SESSION[redirect] = "$base_dir/errorlogin.html";
  50.     }
  51. }
  52.  
  53. //functions that will determine if access is allowed
  54. function allow_access($group)
  55. {
  56.     if ($_SESSION[group1] == "$group" || $_SESSION[group2] == "$group" || $_SESSION[group3] == "$group" ||
  57.         $_SESSION[group1] == "Administrators" || $_SESSION[group2] == "Administrators" || $_SESSION[group3] == "Administrators" ||
  58.         $_SESSION[user_name] == "$group")
  59.         {
  60.             $allowed = "yes";
  61.         }else{
  62.             $allowed = "no";
  63.         }
  64.     return $allowed;
  65. }
  66.  
  67. //function to check the length of the requested password
  68. function password_check($min_pass, $max_pass, $pass)
  69. {
  70.  
  71.     $valid = "yes";
  72.     if ($min_pass > strlen($pass) || $max_pass < strlen($pass))
  73.     {
  74.         $valid = "no";
  75.     }
  76.  
  77.     return $valid;
  78. }
  79.  
  80.  
  81. ////////////////////////////////////////
  82. /////////MY FUNCTIONS//////////////////
  83. //////////////////////////////////////
  84.  
  85. /////////FORMAT//////////////////////
  86.  
  87. function adminheader($title = '')
  88. {  // print an HTML header
  89. ?>
  90. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  91.     <html xmlns="http://www.w3.org/1999/xhtml">
  92.     <head>
  93.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  94.     <title><?php echo $title; ?></title>
  95.     <link href="css/style.css" rel="stylesheet" type="text/css">
  96.     <link href="css/blueberry.css" rel="stylesheet" type="text/css">
  97.     <script src="js/styler.js" type="text/javascript">
  98.     </script>
  99.     </head>
  100.     <body>
  101.     <div id="head-container">
  102.     <div id="header">
  103.     <img src="images/connecticut%20transportation.jpg" />
  104.     <!-- end head-container --></div>
  105.     <!-- end .header --></div>
  106.     <div id="content-container">
  107.     <div class="wrap">
  108. <div id="nav">
  109.         <div class="menu">
  110.             <ul>
  111.                 <li><a class="left_nosub" href="cttsadmin_menu.php">Home</a></li>
  112.                 <li><a class="center_hassub" href="">Employees</a>
  113.                     <ul>
  114.                     <li><a href="list_aides.php">List Aides</a></li>
  115.                     <li><a href="list_drivers.php">List Drivers</a></li>
  116.                     </ul>
  117.                 </li>
  118.                 <li><a class="center_hassub" href="">Clients</a>
  119.                     <ul>
  120.                     <li><a href="list_clients.php">List Clients</a></li>
  121.                     <li><a href="list_schedule.php">List Schedule</a></li>
  122.                     </ul>
  123.                 </li>
  124.                 <li><a class="center_hassub" href="">Schools</a>
  125.                     <ul>
  126.                     <li><a href="list_schools.php">List Schools</a></li>
  127.                 </ul>
  128.                 </li>
  129.                 <li><a class="center_hassub" href="">Cars</a>
  130.                     <ul>
  131.                     <li><a href="list_cars.php">List Cars</a></li>
  132.                     </ul>
  133.                 </li>
  134.                 <li><a class="center_hassub" href="">Routes</a>
  135.                     <ul>
  136.                     <li><a href="">Schedule a Route</a></li>
  137.                     <li><a href="">Veiw Routes</a></li>
  138.                     </ul>
  139.                 </li>
  140.                 <li><a class="center_hassub" href="">My Account</a>
  141.                     <ul>
  142.                     <li><a href="email_change_form.php">Change Your Email</a></li>
  143.                     <li><a href="phone_change_form.php">Change Your Phone Number</a></li>
  144.                     <li><a href="pass_change_form.php">Change Your Password</a></li>
  145.                     <li><a href="mail_all.php">Email ALL Employees</a></li>
  146.                     </ul>
  147.                     </li>
  148.                     <li><a class="center_hassub" href="adminpage.php">User Panel</a>
  149.                     <ul>
  150.                     </ul>
  151.                     </li>
  152.                 <li><a class="right_nosub" href="logout.php">Log Out</a>
  153.                 </li>
  154.                     </ul>
  155.                 </li>
  156.             </ul>
  157.         </div>
  158.         </div>
  159.     <!-- end .myMenu --></div>
  160.     <!-- end .nav --></div>
  161. <!-- end .wrap --></div>
  162. <?php
  163.    
  164. }
  165.  
  166. function adminheader_date($title = '')
  167. {  // print an HTML header
  168. ?>
  169. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  170.     <html xmlns="http://www.w3.org/1999/xhtml">
  171.     <head>
  172.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  173.     <title><?php echo $title; ?></title>
  174.     <link href="css/dark-hive/jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css" />
  175.     <link href="css/style.css" rel="stylesheet" type="text/css">
  176.     <link href="css/blueberry.css" rel="stylesheet" type="text/css">
  177.     <script src="js/styler.js" type="text/javascript">
  178.     </script>
  179.     <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
  180. <script type="text/javascript" src="js/jquery-ui-1.8.22.custom.min.js"></script>
  181. <script type="text/javascript">
  182.             $(function(){
  183.  
  184.                 // Datepicker
  185.                 $('#start_date').datepicker({
  186.                     inline: true,
  187.                 dateFormat: "yy-mm-dd"
  188.                 });
  189.                 // Datepicker
  190.                 $('#end_date').datepicker({
  191.                     inline: true,
  192.                 dateFormat: "yy-mm-dd"
  193.                 });
  194.                
  195.                 //hover states on the static widgets
  196.                 $('#dialog_link, ul#icons li').hover(
  197.                     function() { $(this).addClass('ui-state-hover'); },
  198.                     function() { $(this).removeClass('ui-state-hover'); }
  199.                 );
  200.                
  201.             });
  202.         </script>
  203. <style>
  204. div.ui-datepicker{
  205.  font-size:12px;
  206. }
  207. </style>
  208.     </head>
  209.     <body>
  210.     <div id="head-container">
  211.     <div id="header">
  212.     <img src="images/connecticut%20transportation.jpg" />
  213.     <!-- end head-container --></div>
  214.     <!-- end .header --></div>
  215.     <div id="content-container">
  216.     <div class="wrap">
  217. <div id="nav">
  218.         <div class="menu">
  219.             <ul>
  220.                 <li><a class="left_nosub" href="cttsadmin_menu.php">Home</a></li>
  221.                 <li><a class="center_hassub" href="">Employees</a>
  222.                     <ul>
  223.                     <li><a href="list_aides.php">List Aides</a></li>
  224.                     <li><a href="list_drivers.php">List Drivers</a></li>
  225.                     </ul>
  226.                 </li>
  227.                 <li><a class="center_hassub" href="">Clients</a>
  228.                     <ul>
  229.                     <li><a href="list_clients.php">List Clients</a></li>
  230.                     <li><a href="list_schedule.php">List Schedule</a></li>
  231.                     </ul>
  232.                 </li>
  233.                 <li><a class="center_hassub" href="">Schools</a>
  234.                     <ul>
  235.                     <li><a href="list_schools.php">List Schools</a></li>
  236.                 </ul>
  237.                 </li>
  238.                 <li><a class="center_hassub" href="">Cars</a>
  239.                     <ul>
  240.                     <li><a href="list_cars.php">List Cars</a></li>
  241.                     </ul>
  242.                 </li>
  243.                 <li><a class="center_hassub" href="">Routes</a>
  244.                     <ul>
  245.                     <li><a href="">Schedule a Route</a></li>
  246.                     <li><a href="">Veiw Routes</a></li>
  247.                     </ul>
  248.                 </li>
  249.                 <li><a class="center_hassub" href="">My Account</a>
  250.                     <ul>
  251.                     <li><a href="email_change_form.php">Change Your Email</a></li>
  252.                     <li><a href="phone_change_form.php">Change Your Phone Number</a></li>
  253.                     <li><a href="pass_change_form.php">Change Your Password</a></li>
  254.                     <li><a href="mail_all.php">Email ALL Employees</a></li>
  255.                     </ul>
  256.                     </li>
  257.                     <li><a class="center_hassub" href="adminpage.php">User Panel</a>
  258.                     <ul>
  259.                     </ul>
  260.                     </li>
  261.                 <li><a class="right_nosub" href="logout.php">Log Out</a>
  262.                 </li>
  263.                     </ul>
  264.                 </li>
  265.             </ul>
  266.         </div>
  267.         </div>
  268.     <!-- end .myMenu --></div>
  269.     <!-- end .nav --></div>
  270. <!-- end .wrap --></div>
  271. <?php
  272.    
  273. }
  274.  
  275. function dispatchheader($title = '')
  276. {  // print an HTML header
  277. ?>
  278. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  279. <html xmlns="http://www.w3.org/1999/xhtml">
  280. <head>
  281. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  282. <title></title>
  283. <link href="css/style.css" rel="stylesheet" type="text/css">
  284. <link href="css/blueberry.css" rel="stylesheet" type="text/css">
  285. <script src="js/styler.js" type="text/javascript">
  286. </script>
  287. </head>
  288. <body>
  289. <div id="head-container">
  290. <div id="header">
  291. <img src="images/connecticut%20transportation.jpg" />
  292. <!-- end head-container --></div>
  293. <!-- end .header --></div>
  294. <div id="content-container">
  295. <div class="wrap">
  296. <div id="nav">
  297.         <div class="menu">
  298.             <ul>
  299.                 <li><a class="left_nosub" href="cttsadmin_menu.php">Home</a></li>
  300.                 <li><a class="center_hassub" href="">Routes</a>
  301.                     <ul>
  302.                     <li><a href="">View All Routes</a></li>
  303.                     <li><a href="">Assign Routes</a></li>
  304.                     </ul>
  305.                 </li>
  306.                 <li><a class="center_hassub" href="">My Account</a>
  307.                     <ul>
  308.                     <li><a href="email_change_form.php">Change Your Email</a></li>
  309.                     <li><a href="phone_change_form.php">Change Your Phone Number</a></li>
  310.                     <li><a href="pass_change_form.php">Change Your Password</a></li>
  311.                     <li><a href="mail_all.php">Email ALL Employees</a></li>
  312.                     </ul>
  313.                   </li>
  314.                 <li><a class="right_nosub" href="logout.php">Log Out</a>
  315.                 </li>
  316.                     </ul>
  317.                 </li>
  318.             </ul>
  319.         </div>
  320.         </div>
  321.     <!-- end .myMenu --></div>
  322.     <!-- end .nav --></div>
  323. <!-- end .wrap --></div>
  324. <?php
  325.    
  326. }
  327.  
  328. function driversheader($title = '')
  329. {  // print an HTML header
  330. ?>
  331. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  332. <html xmlns="http://www.w3.org/1999/xhtml">
  333. <head>
  334. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  335. <title></title>
  336. <link href="css/style.css" rel="stylesheet" type="text/css">
  337. <link href="css/blueberry.css" rel="stylesheet" type="text/css">
  338. <script src="js/styler.js" type="text/javascript">
  339. </script>
  340. </head>
  341. <body>
  342. <div id="head-container">
  343. <div id="header">
  344. <img src="images/connecticut%20transportation.jpg" />
  345. <!-- end head-container --></div>
  346. <!-- end .header --></div>
  347. <div id="content-container">
  348. <div class="wrap">
  349. <div id="nav">
  350.         <div class="menu">
  351.             <ul>
  352.                 <li><a class="left_nosub" href="drivers_menu.php">Home</a></li>
  353.                 <li><a class="center_hassub" href="">Routes</a>
  354.                     <ul>
  355.                     <li><a href="">View All Routes</a></li>
  356.                     <li><a href="">View Your Route</a></li>
  357.                     </ul>
  358.                 </li>
  359.                 <li><a class="center_hassub" href="">My Account</a>
  360.                     <ul>
  361.                     <li><a href="email_change_form.php">Change Your Email</a></li>
  362.                     <li><a href="phone_change_form.php">Change Your Phone Number</a></li>
  363.                     <li><a href="pass_change_form.php">Change Your Password</a></li>
  364.                     </ul>
  365.                 </li>
  366.                 <li><a class="right_nosub" href="logout.php">Log Out</a>
  367.                 </li>
  368.             </ul>
  369.         </div>
  370.         </div>
  371.     <!-- end .myMenu --></div>
  372.     <!-- end .nav --></div>
  373. <!-- end .wrap --></div>
  374. <?php
  375.    
  376. }
  377.  
  378. ///////////DATA FUNTIONS//////////////
  379.  
  380. //function to get userid and name for dropdowns in forms
  381. function drivers()
  382. {
  383.  
  384. $result = mysql_query("SELECT * FROM `authorize` WHERE group1='drivers'
  385. OR group2='drivers' OR group3='drivers' ORDER BY lastname");
  386.  
  387. $arr = array();
  388. while($r = mysql_fetch_array($result)){
  389.     $arr[] = $r;
  390.     }
  391. return $arr;
  392.  
  393. }
  394.  
  395. //function to get aides that are active
  396. function aides_active(){
  397.  
  398. $result = mysql_query("Select * FROM `aides` WHERE aides_active = '1' ORDER BY aides_ln");
  399.  
  400. $arr = array();
  401. while($r = mysql_fetch_array($result)){
  402.     $arr[] = $r;
  403.     }
  404. return $arr;
  405. }
  406.  
  407. //function to get cars that are active
  408. function cars(){
  409.  
  410. $result = mysql_query("Select * FROM `cars` WHERE car_active = '1' ORDER BY id_cars");
  411.  
  412. $arr = array();
  413. while($r = mysql_fetch_array($result)){
  414.     $arr[] = $r;
  415.     }
  416. return $arr;
  417. }
  418.  
  419. //function to get schoolid and name for dropdowns in forms
  420. function schools(){
  421.  
  422. $result = mysql_query("Select * FROM `schools` ORDER BY sch_name");
  423.  
  424. $arr = array();
  425. while($r = mysql_fetch_array($result)){
  426.     $arr[] = $r;
  427.     }
  428. return $arr;
  429. }
  430.  
  431. //function to get aides that are active
  432. function clients(){
  433.  
  434. $result = mysql_query("Select * FROM `clients` WHERE cl_active = '1' ORDER BY cl_ln");
  435.  
  436. $arr = array();
  437. while($r = mysql_fetch_array($result)){
  438.     $arr[] = $r;
  439.     }
  440. return $arr;
  441. }
  442.  
  443. //function to get userid and name for dropdowns in forms
  444. function auth_names()
  445. {
  446.  
  447. $result = mysql_query("Select id_auth, firstname, lastname FROM `authorize` ORDERBY lastname");
  448.  
  449. $arr = array();
  450. while($r = mysql_fetch_array($result)){
  451.     $arr[] = $r;
  452.     }
  453. return $arr;
  454. }
  455. //funtion to delete record
  456. $query = "delete from aides where id_ades = '$id_aides'"
  457. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement