예제 #1
0
function sendUserLogsViaMail($classID)
{
    $conn = getMainConnection();
    $query = "SELECT * FROM info WHERE ID = '" . $classID . "'";
    $result = mysql_query($query);
    $numrows = mysql_affected_rows();
    if ($numrows == 1) {
        $member = mysql_fetch_array($result);
        if ($member['activeflag'] != 0) {
            getTemporaryConnection($member['databasename']);
        }
    }
    $query = "SELECT * FROM login_logs WHERE lastlogin <= '" . time() . "' AND lastlogin >= '" . (time() - 86400) . "'";
    $result = mysql_query($query);
    $mail_string = '';
    while ($member = mysql_fetch_array($result)) {
        $time = date("F j, Y, g:i a", $member['lastlogin']);
        $user = getUser($member['userID'])->getName();
        $mail_string .= $user . ' logged in at ' . $time . ' from the ip ' . $member['ip'] . '<br />';
    }
    //echo $mail_string;
    $toEmail = '*****@*****.**';
    $toName = 'Ace Chemistry';
    $fromEmail = '*****@*****.**';
    $fromName = 'My Class - Knowledge Portal';
    $subject = 'Staff Login Logs : ' . date("d-m-Y");
    $body = 'Staff Login Logs <hr /><br />' . $mail_string;
    $flag = sendEmail($toEmail, $toName, $fromEmail, $fromName, $subject, $body, '');
    return $flag;
}
예제 #2
0
function getConnection()
{
    if (isset($_SESSION['api'])) {
        $api = 1;
    } else {
        $api = 0;
    }
    if ($_SESSION['usertype'] == 1 && $api == 0) {
        $database = getCurrentDatabase();
        //$database='myclass_pgt';
    }
    if ($_SESSION['usertype'] == 0 && $api == 0) {
        $database = $_SESSION['db'];
    }
    if ($_SESSION['usertype'] == 3 && $api == 1) {
        $con = getMainConnection();
        $id = $_SESSION['temp_class_ID'];
        $query = "SELECT * FROM info WHERE ID = '" . $id . "'";
        $result = mysql_query($query);
        $numrows = mysql_affected_rows();
        if ($numrows == 1) {
            $member = mysql_fetch_array($result);
            if ($member['activeflag'] != 0) {
                return getTemporaryConnection($member['databasename']);
            }
        }
        return NULL;
    }
    $conn = @mysql_connect(HOST, USER, PASSWORD);
    mysql_select_db($database, $conn);
    return $conn;
}
예제 #3
0
function enterLoginLog($ip, $user)
{
    $conn = getMainConnection();
    $id = $user->getClassID();
    $query = "SELECT * FROM info WHERE ID = '" . $id . "'";
    $result = mysql_query($query);
    $numrows = mysql_affected_rows();
    if ($numrows == 1) {
        $member = mysql_fetch_array($result);
        if ($member['activeflag'] != 0) {
            getTemporaryConnection($member['databasename']);
        }
    }
    $query = "INSERT INTO `login_logs` (`ID`, `userID`, `lastlogin`, `ip`) VALUES (NULL, '" . $user->getID() . "', '" . time() . "', '" . $ip . "')";
    $result = mysql_query($query);
}
예제 #4
0
function updateMainStudentNumber($mainID, $phone_stu)
{
    $conn = getMainConnection();
    $query = "SELECT * FROM `studentinstituteid` WHERE `studentID` = '" . $mainID . "'";
    $result = mysql_query($query, $conn);
    $rows = mysql_num_rows($result);
    if ($result) {
        while ($member = mysql_fetch_array($result)) {
            $tempObj = getInstitute($member['instituteID']);
            $con1 = getTemporaryConnection($tempObj->getDatabaseName());
            $query1 = "UPDATE `student` SET `phone_stu` = '" . $phone_stu . "' WHERE `mainID` = '" . $mainID . "'";
            $result1 = mysql_query($query1, $con1);
        }
        $conn = getMainConnection();
        $query1 = "UPDATE `student` SET `phone_stu` = '" . $phone_stu . "' WHERE `ID` = '" . $mainID . "'";
        $result1 = mysql_query($query1, $conn);
    }
}