function getTimeZoneDateTime($timezone_offset, $timestamp, $date_format, $time_format, $display_format, $return_format)
{
    $tz = get_timezone($timezone_offset);
    // convert offset number to PHP timezone
    date_default_timezone_set($tz);
    switch ($display_format) {
        case "long":
            // Long Format
            if ($date_format == "1") {
                $date = date('l, F j, Y', $timestamp);
            } else {
                $date = date('l j F, Y', $timestamp);
            }
            break;
        case "short":
            // Short Format
            if ($date_format == "1") {
                $date = date('m/d/Y', $timestamp);
            } elseif ($date_format = "2") {
                $date = date('d/m/Y', $timestamp);
            } else {
                $date = date('Y/m/d', $timestamp);
            }
            break;
        case "system":
            // MySQL Format
            $date = date('Y-m-d', $timestamp);
            break;
        case "xml":
            // XML Report Format
            $date = date('l j F Y', $timestamp);
            break;
    }
    if ($time_format == "1") {
        $time = date('H:i', $timestamp);
    } else {
        $time = date('g:i A', $timestamp);
    }
    switch ($return_format) {
        case "date-time":
            $return = $date . " at " . $time . ", " . date('T', $timestamp);
            break;
        case "date-time-no-gmt":
            $return = $date . " at " . $time;
            break;
        case "date-no-gmt":
            $return = $date;
            break;
        case "time-gmt":
            $return = $time . ", " . date('T', $timestamp);
            break;
        case "time":
            $return = $time;
            break;
        default:
            $return = $date;
    }
    return $return;
}
 $mods_db_table = $prefix . "mods";
 $preferences_db_table = $prefix . "preferences";
 $special_best_data_db_table = $prefix . "special_best_data";
 $special_best_info_db_table = $prefix . "special_best_info";
 $sponsors_db_table = $prefix . "sponsors";
 $staff_db_table = $prefix . "staff";
 $styles_db_table = $prefix . "styles";
 $style_types_db_table = $prefix . "style_types";
 $system_db_table = $prefix . "system";
 $themes_db_table = $prefix . "themes";
 $users_db_table = $prefix . "users";
 if ($section == "setup" && ($dbTable == $contest_info_db_table || $dbTable == $drop_off_db_table || $dbTable == $judging_locations_db_table || $dbTable == $styles_db_table || $dbTable == $judging_preferences_db_table || $dbTable == $brewer_db_table || $dbTable == $preferences_db_table)) {
     require DB . 'common.db.php';
     require LIB . 'date_time.lib.php';
     // Set timezone globals for the site
     $timezone_prefs = get_timezone($_SESSION['prefsTimeZone']);
     date_default_timezone_set($timezone_prefs);
     $tz = date_default_timezone_get();
     // Check for Daylight Savings Time (DST) - if true, add one hour to the offset
     $bool = date("I");
     if ($bool == 1) {
         $timezone_offset = number_format($_SESSION['prefsTimeZone'] + 1.0, 0);
     } else {
         $timezone_offset = number_format($_SESSION['prefsTimeZone'], 0);
     }
 }
 // --------------------------- // -------------------------------- //
 if ($action != "purge") {
     function relocate($referer, $page, $msg, $id)
     {
         include CONFIG . "config.php";
Example #3
0
function get_timestamps($dbconn, $login, $scan_START, $scan_SUBMIT, $body)
{
    $user_timezone = $dbconn->GetOne("SELECT timezone FROM users WHERE login='******'");
    $tz = get_timezone($user_timezone);
    if ($tz != 0) {
        $scan_START = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime($scan_START) + 3600 * $tz);
        $scan_SUBMIT = gmdate("Y-m-d H:i:s", Util::get_utc_unixtime($scan_SUBMIT) + 3600 * $tz);
    }
    $body_part_with_timestamp = str_replace("SCAN_SUBMIT", $scan_SUBMIT, $body);
    $body_part_with_timestamp = str_replace("SCAN_START", $scan_START, $body_part_with_timestamp);
    return $body_part_with_timestamp;
}
Example #4
0
/**
 * Function: time_in_timezone
 * Returns the appropriate time() for representing a timezone.
 */
function time_in_timezone($timezone)
{
    $orig = get_timezone();
    set_timezone($timezone);
    $time = date("F jS, Y, g:i A");
    set_timezone($orig);
    return strtotime($time);
}
Example #5
0
function get_date($time_type, $time)
{
    global $CONFIG_time_offset, $CP;
    if ($time) {
        $date = date("{$time_type}", $time + 60 * 60 * (get_timezone("{$CP['time_offset']}") - get_timezone("{$CONFIG_time_offset}")));
    }
    return $date;
}
Example #6
0
// Bug alert: time begins AFTER some time has passed in index.php... gap theory?
// Time zones
global $time_zone_list;
$time_zone_list = array('IDLW' => array(-12, 'Dateline Standard Time', 'Eniwetok, Kwaialein'), 'NT' => array(-11, 'Samoa Standard Time', 'Midway Island, Samoa'), 'HST' => array(-10, 'Hawaii Standard Time', 'Hawaii'), 'AKST' => array(-10, 'Alaskan Standard Time', 'Alaska'), 'YST' => array(-9, 'Yukon Standard Time', 'Yukon, Canada'), 'PST' => array(-8, 'Pacific Standard Time', 'Anchorage, Los Angeles, San Francisco, Seattle'), 'MST' => array(-7, 'Mountain Standard Time', 'Denver, Edmonton, Salt Lake City, Santa Fe'), 'MST-AZ' => array(-7, 'Mountain Standard Time, no DST', 'Arizona and Sonora, no DST'), 'CST' => array(-6, 'Central Standard Time', 'Chicago, Guatemala, Mexico City'), 'SK-UTC-6' => array(-6, 'Sasketchewan Time', 'Saskatchewan East, no DST'), 'EST' => array(-5, 'Eastern Standard Time', 'Bogota, Lima, New York'), 'AST' => array(-4, 'Atlantic Standard Time', 'Caracas, La Paz'), 'NFT' => array(-3.5, 'Newfoundland Time', 'Newfoundland'));
// DST is so much effing fail - flip this when it needs to be
$time_zone_dst = true;
// Fix bugs and anything, force PHP to think in GMT time
putenv('TZ=GMT');
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('GMT');
}
// Get user's time zone and put it in the global namespace
global $time_zone, $time_zone_offset;
$time_zone = '';
$time_zone_offset = 0;
get_timezone();
/**
 * Get user's timezone data and set in global namespace
 */
function get_timezone()
{
    global $user_data, $default_timezone, $time_zone, $time_zone_offset, $time_zone_list, $time_zone_dst;
    $time_zone = empty($user_data['time_zone']) ? empty($default_timezone) ? 0 : $default_timezone : $user_data['time_zone'];
    // TZ is valid...
    if (isset($time_zone_list[$time_zone])) {
        $time_zone_offset = $time_zone_list[$time_zone][0] * 3600;
    } else {
        $time_zone = 'N/A';
    }
}
/**
Example #7
0
function h_entry_from_photo(&$user, &$photo)
{
    $entry = array('published' => null, 'location' => null, 'place_name' => null, 'category' => array(), 'content' => '', 'syndication' => '');
    $entry['published'] = date('c', $photo->created_time);
    // Look up the timezone of the photo if location data is present
    if (property_exists($photo, 'location') && $photo->location) {
        if ($tz = get_timezone($photo->location->latitude, $photo->location->longitude)) {
            $d = DateTime::createFromFormat('U', $photo->created_time);
            $d->setTimeZone($tz);
            $entry['published'] = $d->format('c');
        }
    }
    if ($photo->location) {
        $entry['location'] = 'geo:' . $photo->location->latitude . ',' . $photo->location->longitude;
    }
    if ($photo->location && k($photo->location, 'name')) {
        $entry['place_name'] = k($photo->location, 'name');
    }
    // Add the regular tags to the category array
    if ($photo->tags) {
        $entry['category'] = array_merge($entry['category'], $photo->tags);
    }
    // Add person-tags to the category array
    if ($photo->users_in_photo) {
        foreach ($photo->users_in_photo as $tag) {
            // Fetch the user's website
            try {
                if ($profile = IG\get_profile($user, $tag->user->id)) {
                    if ($profile->website) {
                        $entry['category'][] = $profile->website;
                    } else {
                        $entry['category'][] = 'https://instagram.com/' . $profile->username;
                    }
                    // $entry['category'][] = [
                    //   'type' => ['h-card'],
                    //   'properties' => [
                    //     'name' => [$profile->full_name],
                    //     'url' => [$profile->website],
                    //     'photo' => [$profile->profile_picture]
                    //   ],
                    //   'value' => $profile->website
                    // ];
                }
            } catch (Exception $e) {
                $entry['category'][] = 'https://instagram.com/' . $tag->user->username;
            }
        }
    }
    if ($photo->caption) {
        $entry['content'] = $photo->caption->text;
    }
    $entry['syndication'] = $photo->link;
    return $entry;
}
Example #8
0
					<div class="one-half xs-one-whole">
						<label for="auser">Encryption method</label>
						<select name="hash" class="large" id="hash">' . $hash_options . '</select> 
						<span class="xsmall">(for tests use MD5 else if you are paranoic you can set SHA512 or WHIRLPOOL)</span>
					</div>
					<div class="one-half xs-one-whole">
						<label for="apass">Administrator password *</label>
						<input name="apass" id="apass" type="text" class="large" value="' . $fields['apass']['value'] . '" /> 
						<span class="xsmall">(at least 5 characters)</span>
					</div>
				</div>
				
				<h4 class="zerom triple-gap-top gap-bottom">Global settings</h4>
				<label for="tzone">TimeZone *</label>
				<select name="tzone" class="large" id="tzone">
				' . get_timezone($fields['tzone']['value']) . '
				</select>
				
				<p class="xsmall">NOTE: all fields with * are required</p>
				
				<div class="buttons">
					<button type="submit">Next</button>
				</div>
			</form>
		</div></div>';
        break;
    case 5:
        // INSTALL DB
        $check = false;
        // db connection
        $dsn = empty($_SESSION['dbsocket']) ? 'mysql:host=' . $_SESSION['dbhost'] . ';dbname=' . $_SESSION['dbname'] : 'mysql:unix_socket=' . $_SESSION['dbsocket'] . ';dbname=' . $_SESSION['dbname'];
Example #9
0
/**
 * Get information about process by it identifier (pid)
 *
 * @param int     $pid    The process identifier.
 * @param boolean $stats  If true, additionally show cpu/memory stats
 * @return array          Array with information about process, If process not found, return FALSE
 */
function get_pid_info($pid, $stats = FALSE)
{
    $pid = intval($pid);
    if ($pid < 1) {
        print_debug("Incorrect PID passed");
        //trigger_error("PID ".$pid." doesn't exists", E_USER_WARNING);
        return FALSE;
    }
    if ($stats) {
        // Add CPU/Mem stats
        $options = 'pid,ppid,uid,gid,pcpu,pmem,vsz,rss,tty,stat,time,lstart,args';
    } else {
        $options = 'pid,ppid,uid,gid,tty,stat,time,lstart,args';
    }
    $ps = external_exec('/bin/ps -ww -o ' . $options . ' -p ' . $pid);
    $ps = explode("\n", rtrim($ps));
    if ($GLOBALS['exec_status']['exitcode'] === 127) {
        print_debug("/bin/ps command not found, not possible to get process info.");
        return NULL;
    } else {
        if ($GLOBALS['exec_status']['exitcode'] !== 0 || count($ps) < 2) {
            print_debug("PID " . $pid . " doesn't exists");
            //trigger_error("PID ".$pid." doesn't exists", E_USER_WARNING);
            return FALSE;
        }
    }
    // "  PID  PPID   UID   GID %CPU %MEM    VSZ   RSS TT       STAT     TIME                  STARTED COMMAND"
    // "14675 10250  1000  1000  0.0  0.2 194640 11240 pts/4    S+   00:00:00 Mon Mar 21 14:48:08 2016 php ./test_pid.php"
    //
    // "  PID  PPID   UID   GID TT       STAT     TIME                  STARTED COMMAND"
    // "14675 10250  1000  1000 pts/4    S+   00:00:00 Mon Mar 21 14:48:08 2016 php ./test_pid.php"
    //print_vars($ps);
    $timezone = get_timezone();
    // Get system timezone info, for correct started time conversion
    // Parse output
    $keys = preg_split("/\\s+/", $ps[0], -1, PREG_SPLIT_NO_EMPTY);
    $entries = preg_split("/\\s+/", $ps[1], count($keys) - 1, PREG_SPLIT_NO_EMPTY);
    $started = preg_split("/\\s+/", array_pop($entries), 6, PREG_SPLIT_NO_EMPTY);
    $command = array_pop($started);
    $started[] = str_replace(':', '', $timezone['system']);
    // Add system TZ to started time
    $started_rfc = array_shift($started) . ', ';
    $started_rfc .= implode(' ', $started);
    // Reimplode and convert to RFC2822 started date 'Sun, Mar 20 18:01:53 2016 +0300'
    $entries[] = $started_rfc;
    $entries[] = $command;
    // Readd command
    //print_vars($entries);
    //print_vars($started);
    $pid_info = array();
    foreach ($keys as $i => $key) {
        $pid_info[$key] = $entries[$i];
    }
    $pid_info['STARTED_UNIX'] = strtotime($pid_info['STARTED']);
    //print_vars($pid_info);
    return $pid_info;
}