/** * Get my data from the DB. */ function res_contract_detail() { if (user_access('view emergency info')) { $dbConnect = mssql_connect_estab($conn); $pid = ldap_pbu_id_get_id(); $sql = "SELECT P.COMM_LIFE AS COMM_LIFE, P.RES_CONTRACT AS RES_CONTRACT, p.revision_date as revision_date FROM PBU_WEB_SIGNED_CONTRACTS P WHERE P.people_id='{$pid}'"; $result = mssql_query($sql); if($result === false || !mssql_num_rows($result)) { drupal_set_message(t('ERROR: No Resident Contract info on File for you.'), 'error'); } else { } $row = mssql_fetch_assoc($result); return $row; } } /** * Called when the user goes to the page. */ function res_contract_page() { $rec = res_contract_detail(); $myVarz = variable_get('res_contract_days', ''); //date to compare $rev_date = $rec['revision_date']; //get todays datetime in seconds $today = time(); //global days variable into seconds $comp = $myVarz * 86400; //convert MSSQL datetime to unix epoch time. $dbTime = strptime($rev_date, '%Y-%m-%d %H:%M:%S'); //$revInt = mktime($dbTime['tm_hour'], $dbTime['tm_min'], $dbTime['tm_sec'], $dbTime['tm_mon'], $dbTime['tm_mday'], $dbTime['tm_year']); $revInt = mktime(0, 0, 0, $dbTime['tm_mon'], $dbTime['tm_mday'], $dbTime['tm_year']); //today in seconds minus revision_datatime in seconds $diff = $today - $revInt; //figure out many days that result is then round it. $diff2 = $diff/86400; $diff3 = array(); $diff3 = round($diff2); //if it is more than the limit, show the form if ($diff > $comp) { drupal_set_message(t('Your data is !days days old.', array('!days' => $diff3)), 'error'); $output .= t('
HERE ARE MY TERMS. ACCEPT OR DIE.
'); $output .= t('DB Date:'. $rev_date .'