$pagecontent .= '<div class="notification red"><p>The article does not exist.</p></div>';
         }
     } else {
         $pagecontent .= '<div class="notification red"><p>The article does not exist.</p></div>';
     }
 } elseif (isset($_GET['new'])) {
     $redmsg = "";
     $greenmsg = "";
     $fail = FALSE;
     $content = '';
     $title = '';
     if (isset($_POST['save'])) {
         $news = new anno($sql);
         $news->divid = 0;
         $news->userid = $sessus->id;
         $news->datetime = currentTime();
         if (isset($_POST['title'])) {
             if (strlen($_POST['title']) >= 3 && strlen($_POST['title']) <= 50) {
                 $news->title = $_POST['title'];
             } else {
                 $fail = TRUE;
                 $redmsg .= "<p>You must have a title between 3 and 50 characters.</p>";
             }
         } else {
             $fail = TRUE;
             $redmsg .= "<p>You must have a title between 3 and 50 characters.</p>";
         }
         if (isset($_POST['content'])) {
             $news->text = $_POST['content'];
         } else {
             $fail = TRUE;
            if ($_POST['password'] != $_POST['password2']) {
                $error['top'] .= "<p>Both passwords must be identical.</p>";
                $error['password2'] = "Both passwords must be identical.";
            } else {
                $filled['password'] = TRUE;
            }
        }
        $isfilled = TRUE;
    } else {
        $error['top'] .= "<p>Both passwords must be identical.</p>";
        $error['password2'] = "Both passwords must be identical.";
    }
    if ($isfilled == TRUE && $filled['username'] == TRUE && $filled['email'] == TRUE && $filled['password'] == TRUE) {
        $user = new user($sql, "username", $_POST['username']);
        $user->email = $_POST['email'];
        $user->membersince = currentTime();
        $user->logLogin();
        if ($user->changePW($_POST['password'])) {
            if ($user->save()) {
                $user->load();
                $_SESSION['userid'] = $user->id;
                $pagecontent .= '
					<div class="notification green">
						<p>Your account has been created.</p>
					</div>';
            } else {
                $pagecontent .= '
					<div class="notification red">
						<p>Failed to save user.</p>
					</div>';
            }
 public function logLogin()
 {
     if (isset($this->id)) {
         if ($log = $this->sql->prepare("INSERT INTO wolfvtc_logins (userid, datetime, ip) VALUES (?, ?, ?)")) {
             $log->bind_param("iss", $this->id, currentTime(), $_SERVER['REMOTE_ADDR']);
             if ($log->execute()) {
                 return TRUE;
             } else {
                 return FALSE;
             }
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }
Exemple #4
0
function checkEmergencyLane()
{
    $avgTimeForOnePerson = 10;
    //average time(in normal condition) for each person after collecting boarding pass to pass the security barrier
    //variable $no which stores the number  of customers who havent got boarding pass
    $no = 0;
    //provides current time(in min)add for 30 min
    $currentTime = currentTime() + 30;
    //convert the time(min form) into hour:min (after 30 min)type
    $hour = intval($currentTime / 60);
    $min = $currentTime % 60;
    //adding zero if hour or min is in single digit
    if ($hour < 10) {
        $hour = "0" . $hour;
    }
    if ($min < 10) {
        $min = "0" . $min;
    }
    //converting time to string
    $time = $hour . $min;
    //getting the current time in form of string
    $current = date("H:i");
    $current = explode(":", $current);
    $current = $current[0] . $current[1];
    //fetching id of flights in next 30min
    $query = "select id from flight where time < '" . $time . "' and time > '" . $current . "'";
    $query = mysql_query($query) or die(mysql_error());
    //$result = mysql_fetch_assoc($query);
    if ($query) {
        //this means there is some flight in next 30 min
        while ($result = mysql_fetch_assoc($query)) {
            //now check the status of each customer of  that particular flight
            $no += getCustomerStatus($result['id']);
        }
        //in the end of while loop $no will be containing total no of person that are going to coming and having flight in next 30 min
        if ($no != 0) {
            //$no --> no of pending persons for next 30 min
            //$noOfEmergencyLane contains the total no of emgerncy lane
            //$getStanding contains total person standing in emergencyLane
            $emergencyLaneId = emergencyCase();
            //list of id for emergency Lane
            $temp = getNoOfPersonStandingEmergency($emergencyLaneId);
            $temp = explode(":", $temp);
            $totalPersonStanding = $temp[0];
            $noOfEmergencyLane = $temp[1];
            //(total pending person + no standing person)/(no of emeg lane)
            $avgCapacityOfOneEmergencyLane = intval(($no + $totalPersonStanding) / $noOfEmergencyLane);
            echo $avgCapacityOfOneEmergencyLane;
            $averageTimeForEachLane = $avgTimeForOnePerson * $avgCapacityOfOneEmergencyLane;
            //this will tell me the average time for making that queue empty
            if ($averageTimeForEachLane < 30) {
                //means emergencyCase  lane can be allocated.so find lane with minimum no of persons
                return getMinEmergencyLane();
            } else {
                return getMinLane();
            }
        } else {
            //in this case there is flight and every1 has already bored so all the lanes are option for this moment
            return getMinLane();
        }
    } else {
        //means no flight in next 30 min so emergency lanes will be avialble
        //so we can check that in which lane it less no of people are present and then compare with the noraml lane rush. what so ever is minimum that will be allocated
        // so finding the min number value in security lane and assign to the customer
        $result = getMinLane();
        return $result;
        //this lane will be alloacted to customer
    }
}
Exemple #5
0
function sendMailLocalUse($action, $group)
{
    include_once 'Mail.php';
    include_once 'Mail/mime.php';
    global $input;
    $subject = getMailSubject($action);
    $html = getMailContent($action);
    $cursor = mongoFind(DB, 'priviledge', array('role' => $group, 'country' => $_SESSION['location']), array('user' => true));
    $pushedArray = array();
    while ($cursor->hasNext()) {
        $r = $cursor->getNext();
        array_push($pushedArray, $r['user']);
    }
    $recipient = array('to' => array());
    foreach ($pushedArray as $userName) {
        $email = getEmailFromUserAccount($userName);
        array_push($recipient['to'], $email[0]['mail'][0]);
    }
    /* SMTP server name, port, user/passwd */
    $smtpInfo = array("host" => "10.16.11.68", "port" => "25", "auth" => false);
    $recipients = join(',', $recipient['to']) . (isset($recipient['cc']) ? ', ' . $recipient['cc'] : '') . (isset($recipient['bcc']) ? ', ' . $recipient['bcc'] : '');
    $crlf = "\n";
    $headers = array("From" => "*****@*****.**", "To" => join(',', $recipient['to']), "Subject" => $subject);
    if (isset($recipient['cc'])) {
        $headers['Cc'] = $recipient['cc'];
    }
    if (isset($recipient['bcc'])) {
        $headers['Bcc'] = $recipient['bcc'];
    }
    /*Creating the Mime message*/
    $mime = new Mail_mime($crlf);
    /*Setting the body of the email*/
    /*$mime->setTXTBody($body);*/
    $mime->setHTMLBody($html);
    $body = $mime->get();
    $headers = $mime->headers($headers);
    /* Create the mail object using the Mail::factory method */
    $mail_object =& Mail::factory("smtp", $smtpInfo);
    /* Ok send mail */
    $mail_object->send($recipients, $headers, $body);
    error_log(currentTime() . $subject . ' ' . 'e-mail has been sent to' . ' ' . $recipients);
}