Пример #1
0
/**
* Check if the given gedcom record has changed since the last session access
* This is used to check if the gedcom record changed between the time the user
* loaded the individual page and the time they clicked on a link to edit
* the data.
*
* @param string $pid The gedcom id of the record to check pgv_changes
* @param string $gedrec The latest gedcom record to check the CHAN:DATE:TIME (auto accept)
*/
function checkChangeTime($pid, $gedrec, $last_time)
{
    global $GEDCOM, $pgv_changes, $pgv_lang;
    //-- check if the record changes since last access
    $changeTime = 0;
    $changeUser = "";
    if (isset($pgv_changes[$pid . "_" . $GEDCOM])) {
        $change = end($pgv_changes[$pid . "_" . $GEDCOM]);
        $changeTime = $change['time'];
        $changeUser = $change['user'];
    } else {
        $changrec = get_sub_record(1, "1 CHAN", $gedrec);
        $cdate = get_gedcom_value("DATE", 2, $changrec, '', false);
        if (!empty($cdate)) {
            $ctime = get_gedcom_value("DATE:TIME", 2, $changrec);
            $changeUser = get_gedcom_value("_PGVU", 2, $changrec, '', false);
            $chan_date = new GedcomDate($cdate);
            $chan_date = $chan_date->MinDate();
            $chan_time = parse_time($ctime);
            $changeTime = mktime($chan_time[0], $chan_time[1], $chan_time[2], $chan_date->m, $chan_date->d, $chan_date->y);
        }
    }
    if (isset($_REQUEST['linenum']) && $changeTime != 0 && $last_time && $changeTime > $last_time) {
        echo "<span class=\"error\">" . preg_replace("/#PID#/", $pid, $pgv_lang["edit_concurrency_msg2"]) . "<br /><br />";
        if (!empty($changeUser)) {
            echo preg_replace(array("/#CHANGEUSER#/", "/#CHANGEDATE#/"), array($changeUser, date("d M Y H:i:s", $changeTime)), $pgv_lang["edit_concurrency_change"]) . "<br /><br />";
        }
        echo $pgv_lang["edit_concurrency_reload"] . "</span>";
        print_simple_footer();
        exit;
    }
}
Пример #2
0
 function get_form($prefix, $value)
 {
     $time = parse_time($value);
     $form = "";
     $form .= create_select_form("{$prefix}_hour", false, format_range("%2d", $this->start_hour, $this->end_hour), "", $time[0]);
     $form .= ":";
     $form .= create_select_form("{$prefix}_min", false, format_range("%02d", 0, 59, $this->min_step), "", $time[1]);
     return $form;
 }
Пример #3
0
 /** @test */
 public function itCanUnderstandSomeCommonTimes()
 {
     $actual = parse_time('11 AM - Midnight', true);
     $expected = [['hour' => 11], ['hour' => 0]];
     $this->assertEquals($expected[0]['hour'], $actual[0]['hour']);
     $this->assertEquals($expected[1]['hour'], $actual[1]['hour']);
 }
Пример #4
0
function ah_time_left($exp_time) {
	global $current_time;
	global $lang;

	$time_left = $exp_time - $current_time;

	if($time_left > 0) {
		print_time(parse_time($time_left));
	}
	else echo "<font class='expired'>" . $lang['ah_expired'] . "</font>";
}
Пример #5
0
 function _match_user(&$user, $line)
 {
     #attflotten matching
     #    var_dump($line);
     #    echo "<br><br>";
     $fleet_list = array();
     if (preg_match_all("'(?:(Rückflug)\\s*?<br>|)[\\s\\(]*?(\\d{1,4}):(\\d{1,2})\\s*?([^\\s\\)<]+).*?<br>'is", $line[4], $att_fleets, PREG_SET_ORDER)) {
         $timelist = parse_time($line[5]);
         for ($i = 0; $i < count($att_fleets); $i++) {
             $fleet =& $att_fleets[$i];
             if ($fleet[1] == "Rückflug") {
                 $fleet['return_flight'] = 1;
             } else {
                 $fleet['return_flight'] = 0;
             }
             $fleet['status'] = 1;
             if ($fleet['return_flight']) {
                 $title = "<span class=\"blue\">Angriff Rückflug</span> von";
                 $select = "Angriff Rückflug von";
             } else {
                 $title = "<span class=\"red\">Angriff</span> auf";
                 $select = "Angriff auf";
             }
             $eta = $timelist[$i] * 60;
             $title .= " {$fleet['4']} ({$fleet['2']}:{$fleet['3']}) ETA " . $this->formattime($eta, true);
             $select .= " {$fleet['4']} ({$fleet['2']}:{$fleet['3']}) ETA " . $this->formattime($eta, true);
             $fleet_list[] = array("status" => $fleet['status'], "gala" => $fleet[2], "pos" => $fleet[3], "nick" => $fleet[4], "eta" => $eta, "return_flight" => $fleet['return_flight']);
             $titles[] = $title;
             $select_box[] = array("value" => $i + 1, "title" => $select);
         }
     }
     if (preg_match_all("'(?:(Rückflug)\\s*?<br>|)[\\s\\(]*?(\\d{1,4}):(\\d{1,2})\\s*?([^\\s\\)<]+).*?<br>'is", $line[6], $att_fleets, PREG_SET_ORDER)) {
         $timelist = parse_time($line[7]);
         for ($i = 0; $i < count($att_fleets); $i++) {
             $fleet =& $att_fleets[$i];
             if ($fleet[1] == "Rückflug") {
                 $fleet['return_flight'] = 1;
             } else {
                 $fleet['return_flight'] = 0;
             }
             $fleet['status'] = 2;
             if ($fleet['return_flight']) {
                 $title = "<span class=\"blue\">Verteidigung Rückflug</span> von";
                 $select = "Verteidigung Rückflug von";
             } else {
                 $title = "<span class=\"green\">Verteidigung</span> von";
                 $select = "Verteidigung von";
             }
             $eta = $timelist[$i] * 60;
             $title .= " {$fleet['4']} ({$fleet['2']}:{$fleet['3']}) ETA " . $this->formattime($eta, true);
             $select .= " {$fleet['4']} ({$fleet['2']}:{$fleet['3']}) ETA " . $this->formattime($eta, true);
             $fleet_list[] = array("status" => $fleet['status'], "gala" => $fleet[2], "pos" => $fleet[3], "nick" => $fleet[4], "eta" => $eta, "return_flight" => $fleet["return_flight"]);
             $titles[] = $title;
             $select_box[] = array("value" => $i + 1, "title" => $select);
         }
     }
     $fleet = array();
     $userfleets = listFleetsByUser($user['uid']);
     if (count($fleet_list) == 0) {
         // beide flotten im orbit
         $do_update = array(1, 1);
         $do_selectbox = array(0, 0);
         $fleet = array();
     } elseif (count($fleet_list) == 1 && $user['fleettype'] && $fleet_list[0]['status'] == 1 && $user['fleettype'] == 2) {
         // flotte 1 attet, flotte 2 im orbit
         // mit db checken
         if ($this->_is_matched_fleet($userfleets[1], $fleet_list[0])) {
             // is in db, kein update
             $do_update = array(0, 1);
         } else {
             // is nicht in db
             $do_update = array(1, 1);
         }
         $do_selectbox = array(0, 0);
         $fleet[0] = $fleet_list[0];
     } elseif (count($fleet_list) == 1 && $user['fleettype'] && $fleet_list[0]['status'] == 2 && $user['fleettype'] == 1) {
         // flotte 1 defft, flotte 2 im orbit
         // mit db checken
         if ($this->_is_matched_fleet($userfleets[1], $fleet_list[0])) {
             // is in db, kein update
             $do_update = array(0, 1);
         } else {
             // is nicht in db
             $do_update = array(1, 1);
         }
         $do_selectbox = array(0, 0);
         $fleet[0] = $fleet_list[0];
         #echo "flotte 1 defft, flotte 2 im orbit<br>";
     } elseif (count($fleet_list) == 2 && $user['fleettype'] && $fleet_list[0]['status'] != $fleet_list[1]['status']) {
         // flotten beide unterwegs, status unterschiedlich
         if ($user['fleettype'] == 2) {
             // flotte 2 defft, flotte 1 attet
             $fleet[0] = $fleet_list[0];
             $fleet[1] = $fleet_list[1];
         } else {
             // flotte 1 defft, flotte 2 attet
             $fleet[0] = $fleet_list[1];
             $fleet[1] = $fleet_list[0];
             $title_dummy = $titles[0];
             $titles[0] = $titles[1];
             $titles[1] = $title_dummy;
         }
         if ($this->_is_matched_fleet($userfleets[1], $fleet_list[0])) {
             // is in db, kein update
             $do_update[0] = 0;
         } else {
             // is nicht in db
             $do_update[0] = 1;
         }
         if ($this->_is_matched_fleet($userfleets[2], $fleet_list[1])) {
             // is in db, kein update
             $do_update[1] = 0;
         } else {
             // is nicht in db
             $do_update[1] = 1;
         }
     } else {
         // keine ahnung
         $do_update = array(1, 1);
         $do_selectbox = array(1, 1);
         $fleet = $fleet_list;
         if (!count($fleet[1])) {
             $fleet[] = array("status" => 0);
             $titles[] = "Im Orbit";
             $select_box[] = array("value" => 2, "title" => "Im Orbit");
         }
     }
     for ($i = 0; $i < 2; $i++) {
         $hidden_string[$i]['do_update'] = $do_update[$i];
         $hidden_string[$i]['do_selectbox'] = $do_selectbox[$i];
         $hidden_string[$i]['status'] = $fleet[$i]['status'];
         $hidden_string[$i]['gala'] = $fleet[$i]['gala'];
         $hidden_string[$i]['pos'] = $fleet[$i]['pos'];
         $hidden_string[$i]['eta'] = $fleet[$i]['eta'];
         $hidden_string[$i]['return_flight'] = $fleet[$i]['return_flight'];
         #      var_dump($hidden_string[$i]);echo"<br>";
         #      var_dump(join(",",$hidden_string[$i]));echo"<br>";
         $hidden_string[$i] = urlencode(join(",", $hidden_string[$i]));
         if (!$titles[$i]) {
             $titles[$i] = "Im Orbit";
         }
         $user['form_data'][] = array("title" => $titles[$i], "fleet" => $i + 1, "do_selectbox" => $do_selectbox[$i], "select_box" => $select_box);
     }
     $user['hidden_string'] = join("#", $hidden_string);
     #    if($user['nick'] == "Schmog") {
     #      var_dump($fleet_list);
     #      echo "<br><br>";
     #      echo "userfleettype: ".$user['fleettype']."<br>";
     #      var_dump($fleet);
     #      echo "<br><br>";
     #      var_dump($titles);
     #      echo "<br><br>";
     #      exit();
     #    }
 }
Пример #6
0
while (!feof($file)) {
    $line = fgets($file);
    $row_count++;
    if ($row_count <= $added_row_count) {
        continue;
    }
    if ($row_count - $added_row_count > 200) {
        $row_count--;
        break;
    }
    $row_string = "<tr>";
    if (is_numeric($line[0])) {
        $line = convert_seperator($line);
        $cells = explode("|", $line);
        // Date & Time
        $time = parse_time($cells[0]);
        if ($time == $last_time) {
            $duplicated_count++;
            $time += $duplicated_count * 60 * 60;
        } else {
            $last_time = $time;
            $duplicated_count = 0;
        }
        $row_string .= "<td>" . date('d-m-Y H:i:s', $time) . "</td>";
        // Category
        $category = $cells[1];
        $row_string .= "<td>" . $category . "</td>";
        $category_id = "&nbsp;";
        foreach ($cate_list as $cate) {
            if ($cate['Name'] == $category) {
                $category_id = $cate['Id'];
Пример #7
0
function mod_ban_post($board, $delete, $post, $token = false)
{
    global $config, $mod;
    if (!openBoard($board)) {
        error($config['error']['noboard']);
    }
    if (!hasPermission($config['mod']['delete'], $board)) {
        error($config['error']['noaccess']);
    }
    $security_token = make_secure_link_token($board . '/ban/' . $post);
    $query = prepare(sprintf('SELECT `ip`, `thread` FROM `posts_%s` WHERE `id` = :id', $board));
    $query->bindValue(':id', $post);
    $query->execute() or error(db_error($query));
    if (!($_post = $query->fetch(PDO::FETCH_ASSOC))) {
        error($config['error']['404']);
    }
    $thread = $_post['thread'];
    $ip = $_post['ip'];
    if (isset($_POST['new_ban'], $_POST['reason'], $_POST['length'], $_POST['board'])) {
        require_once 'inc/mod/ban.php';
        if (isset($_POST['ip'])) {
            $ip = $_POST['ip'];
        }
        ban($ip, $_POST['reason'], parse_time($_POST['length']), $_POST['board'] == '*' ? false : $_POST['board']);
        if (isset($_POST['public_message'], $_POST['message'])) {
            // public ban message
            $query = prepare(sprintf('UPDATE `posts_%s` SET `body` = CONCAT(`body`, :body) WHERE `id` = :id', $board));
            $query->bindValue(':id', $post);
            $query->bindValue(':body', sprintf($config['mod']['ban_message'], utf8tohtml($_POST['message'])));
            $query->execute() or error(db_error($query));
            modLog("Attached a public ban message to post #{$post}: " . utf8tohtml($_POST['message']));
            buildThread($thread ? $thread : $post);
            buildIndex();
        } elseif (isset($_POST['delete']) && (int) $_POST['delete']) {
            // Delete post
            deletePost($post);
            modLog("Deleted post #{$post}");
            // Rebuild board
            buildIndex();
        }
        header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
    }
    $args = array('ip' => $ip, 'hide_ip' => !hasPermission($config['mod']['show_ip'], $board), 'post' => $post, 'board' => $board, 'delete' => (bool) $delete, 'boards' => listBoards(), 'token' => $security_token);
    mod_page(_('New ban'), 'mod/ban_form.html', $args);
}
Пример #8
0
 /**
  * merge a local gedcom record with the information from the remote site
  * @param string $xref the remote ID to merge with
  * @param string $localrec the local gedcom record to merge the remote record with
  * @param boolean $isStub whether or not this is a stub record
  * @param boolean $firstLink is this the first time this record is being linked
  */
 function mergeGedcomRecord($xref, $localrec, $isStub = false, $firstLink = false)
 {
     global $FILE, $GEDCOM;
     global $TBLPREFIX, $pgv_changes;
     $FILE = $GEDCOM;
     if (!$isStub) {
         $gedrec = find_gedcom_record($this->xref . ":" . $xref);
         if (!empty($gedrec)) {
             $localrec = $gedrec;
         }
     }
     //-- used to force an update on the first time linking a person
     if ($firstLink) {
         $this->authenticate();
         $result = $this->soapClient->getGedcomRecord($this->SID, $xref);
         if (PEAR::isError($result) || isset($result->faultcode) || get_class($result) == 'SOAP_Fault' || is_object($result)) {
             if (isset($result->faultstring)) {
                 AddToLog($result->faultstring);
                 print $result->faultstring;
             }
             return $localrec;
         }
         $gedrec = $result;
         $gedrec = preg_replace("/@([^#@\\s]+)@/", "@" . $this->xref . ":\$1@", $gedrec);
         $gedrec = $this->checkIds($gedrec);
         $localrec = $this->_merge($localrec, $gedrec);
         include_once "includes/functions/functions_edit.php";
         $localrec = $this->UpdateFamily($localrec, $gedrec);
         $ct = preg_match("/0 @(.*)@/", $localrec, $match);
         if ($ct > 0) {
             $pid = trim($match[1]);
             replace_gedrec($pid, $localrec);
         }
     }
     //-- get the last change date of the record
     $change_date = get_gedcom_value("CHAN:DATE", 1, $localrec, '', false);
     if (empty($change_date)) {
         $this->authenticate();
         if (!is_object($this->soapClient) || $this->isError($this->soapClient)) {
             return false;
         }
         $result = $this->soapClient->getGedcomRecord($this->SID, $xref);
         if (PEAR::isError($result) || isset($result->faultcode) || get_class($result) == 'SOAP_Fault' || is_object($result)) {
             if (isset($result->faultstring)) {
                 AddToLog($result->faultstring);
                 print $result->faultstring;
             }
             return $localrec;
         }
         $gedrec = $result;
         $gedrec = preg_replace("/@([^#@\\s]+)@/", "@" . $this->xref . ":\$1@", $gedrec);
         $gedrec = $this->checkIds($gedrec);
         $localrec = $this->_merge($localrec, $gedrec);
         $ct = preg_match("/0 @(.*)@/", $localrec, $match);
         if ($ct > 0) {
             $pid = trim($match[1]);
             if ($isStub) {
                 include_once "includes/functions/functions_edit.php";
                 $localrec = $this->UpdateFamily($localrec, $gedrec);
                 replace_gedrec($pid, $localrec);
             } else {
                 update_record($localrec);
             }
         }
     } else {
         $chan_date = new GedcomDate($change_date);
         $chan_time_str = get_gedcom_value("CHAN:DATE:TIME", 1, $localrec, '', false);
         $chan_time = parse_time($chan_time_str);
         $change_time = mktime($chan_time[0], $chan_time[1], $chan_time[2], $chan_date->date1->m, $chan_date->date1->d, $chan_date->date1->y);
         /**
          * @todo make the timeout a config option
          */
         // Time Clock (determines how often a record is checked)
         if ($change_time < time() - 60 * 60 * 24 * 14) {
             //$change_date= "1 JAN 2000";
             $this->authenticate();
             if (!is_object($this->soapClient) || $this->isError($this->soapClient)) {
                 return false;
             }
             $person = $this->soapClient->checkUpdatesByID($this->SID, $xref, $change_date);
             // If there are no changes between the local and remote copies
             if (PEAR::isError($person) || isset($person->faultcode) || get_class($person) == 'SOAP_Fault' || isset($person->error_message_prefix)) {
                 if (isset($person->faultstring)) {
                     AddToLog($person->faultstring);
                 } else {
                     AddToLog($person->message);
                 }
                 //-- update the last change time
                 $pos1 = strpos($localrec, "1 CHAN");
                 if ($pos1 !== false) {
                     $pos2 = strpos($localrec, "\n1", $pos1 + 4);
                     if ($pos2 === false) {
                         $pos2 = strlen($localrec);
                     }
                     $newgedrec = substr($localrec, 0, $pos1);
                     $newgedrec .= "1 CHAN\n2 DATE " . date("d M Y") . "\n";
                     $newgedrec .= "3 TIME " . date("H:i:s") . "\n";
                     $newgedrec .= "2 _PGVU @" . $this->xref . "@\n";
                     $newgedrec .= substr($localrec, $pos2);
                     $localrec = $newgedrec;
                 } else {
                     $newgedrec = "\n1 CHAN\n2 DATE " . date("d M Y") . "\n";
                     $newgedrec .= "3 TIME " . date("H:i:s") . "\n";
                     $newgedrec .= "2 _PGVU @" . $this->xref . "@";
                     $localrec .= $newgedrec;
                 }
                 update_record($localrec);
             } else {
                 $gedrec = $person->gedcom;
                 $gedrec = preg_replace("/@([^#@\\s]+)@/", "@" . $this->xref . ":\$1@", $gedrec);
                 $gedrec = $this->checkIds($gedrec);
                 $ct = preg_match("/0 @(.*)@/", $localrec, $match);
                 if ($ct > 0) {
                     $pid = trim($match[1]);
                     if (isset($pgv_changes[$pid . "_" . $GEDCOM])) {
                         $localrec = find_updated_record($pid);
                     }
                     $localrec = $this->_merge($localrec, $gedrec);
                     if ($isStub) {
                         include_once "includes/functions/functions_edit.php";
                         $localrec = $this->UpdateFamily($localrec, $gedrec);
                         replace_gedrec($pid, $localrec);
                     } else {
                         update_record($localrec);
                     }
                 }
             }
         }
     }
     return $localrec;
 }
Пример #9
0
function rot_hpc($x, $y, $tstart, $tend, $spacecraft = null, $vstart = null, $vend = null)
{
    /* Given a location on the Sun referred to using the Helioprojective Cartesian
          co-ordinate system in the units of arcseconds, use the solar rotation
          profile to find that location at some later or earlier time.
       
          Parameters
          -----------
          x: float or numpy ndarray
             helio-projective x-co-ordinate in arcseconds
       
          y: float or numpy ndarray
             helio-projective y-co-ordinate in arcseconds
      
      
          tstart: date/time to which x and y are referred; can be in any acceptable
             time format.
      
          tend: Date/time at which x and y will be rotated to; can be
             in any acceptable time format.
      
          spacecraft: { None | "soho" | "stereo_a" | "stereo_b" }
             calculate the rotation from the point of view of the SOHO,
             STEREO A, or STEREO B spacecraft.
       
       TODO: the ability to do this rotation for data from the SOHO
             point of view and the STEREO A, B point of views.
       
          See Also
          --------
          IDL code equavalent:
             http://hesperia.gsfc.nasa.gov/ssw/gen/idl/solar/rot_xy.pro
       
          Note: rot_xy uses arcmin2hel.pro and hel2arcmin.pro to implement the
          same functionality.  These two functions seem to perform inverse
          operations of each other to a high accuracy.  The corresponding
          equivalent functions here are convert_hpc_hg and convert_hg_hpc
          respectively.  These two functions seem to perform inverse
          operations of each other to a high accuracy.  However, the values
          returned by arcmin2hel.pro are slightly different from those provided
          by convert_hpc_hg.  This leads to slightly different results from
          rot_hpc compared to rot_xy.
       */
    # must have pairs of co-ordinates
    if (count($x) != count($y) || is_scalar($x) !== is_scalar($y)) {
        throw new Exception('Input co-ordinates must have the same shape.');
    }
    # Make sure we have enough time information to perform a solar differential
    # rotation
    # Start time
    $dstart = parse_time($tstart);
    $dend = parse_time($tend);
    # Fractional days
    $interval = ($dend->format('U') - $dstart->format('U')) / 60.0 / 60.0 / 24.0;
    # Get the Sun's position from the vantage point at the start time
    if ($vstart === null) {
        $vstart = pb0r($dstart, $spacecraft);
    }
    # Compute heliographic co-ordinates - returns (longitude, latitude). Points
    # off the limb are returned as NaN
    list($longitude, $latitude) = convert_hpc_hg(RADIUS, AU * sunearth_distance($t = $dstart), 'arcsec', 'arcsec', $vstart["b0"], $vstart["l0"], $x, $y);
    # Compute the differential rotation
    $drot = diff_rot($interval, $latitude, $frame_time = 'synodic');
    # Convert back to heliocentric cartesian in units of arcseconds
    if ($vend === null) {
        $vend = pb0r($dend, $spacecraft);
    }
    # It appears that there is a difference in how the SSWIDL function
    # hel2arcmin and the function below performs this co-ordinate
    # transform.
    list($newx, $newy) = convert_hg_hpc(RADIUS, AU * sunearth_distance($t = $dend), $vend["b0"], $vend["l0"], $longitude + $drot, $latitude, $units = 'arcsec');
    return array($newx, $newy);
}
Пример #10
0
<?php write_metalborder_header(); ?>
    <table cellpadding="3" cellspacing="0" width="100%">
        <tbody>
        <tr>
            <td class="rankingHeader" align="left" nowrap="nowrap" width="53"><div align="center"><?php echo $lang['status'];?></div></td>
            <td align="left" nowrap="nowrap" class="rankingHeader"><div align="center"><?php echo $lang['uptime'];?></div></td>
            <td align="left" nowrap="nowrap" class="rankingHeader"><?php echo $lang['realm_name'];?></td>
            <td class="rankingHeader" align="center" nowrap="nowrap" width="120"><?php echo $lang['si_type'];?></td>
            <td class="rankingHeader" align="center" nowrap="nowrap" width="120"><?php echo $lang['si_pop'];?></td>
        </tr>
        <tr>
            <td colspan="6" style="background: url('<?php echo $currtmp; ?>/images/shadow.gif');">
                <img src="<?php echo $currtmp; ?>/images/pixel.gif" height="1" width="1" alt=""/>
            </td>
        </tr>
<?php foreach($items as $item): ?>
        <tr>
            <td class="serverStatus<?php echo $item['res_color'] ?>" align="center"><img src="<?php echo $item['img']; ?>" height='18' width='18' alt=""/></td>
            <td width="168" class="serverStatus<?php echo $item['res_color'] ?>"><div align="center">
                <?php if($item['uptime'] != 0) { print_time(parse_time($item['uptime'])); } ?>
            </div></td>
            <td width="802" class="serverStatus<?php echo $item['res_color'] ?>"><b style='color: rgb(35, 67, 3);'><?php echo $item['name']; ?></b></td>
            <td class="serverStatus<?php echo $item['res_color'] ?>" align="center"><b style='color: rgb(102, 13, 2);'><?php echo $item['type']; ?></b></td>
            <td class="serverStatus<?php echo $item['res_color'] ?>" align="center"><b style='color: rgb(35, 67, 3);'><?php echo $item['pop']." (".population_view($item['pop']).")"; ?></b></td>
        </tr>
<?php endforeach; ?>
        </tbody>
    </table>
<?php write_metalborder_footer(); ?>
<?php builddiv_end() ?>
    if (check_port_status($result['address'], $result['port'], 2) == TRUE) {
        // res image is the up arrow pretty much
        $res_img = 'Online';
        // Get the server population
        $population = $CDB_EXTRA->count("SELECT COUNT(*) FROM `characters` WHERE online=1");
        // Get the server uptime
        $start_time = $DB->selectCell("SELECT `starttime` FROM `uptime` WHERE `realmid`='" . $realm_num . "' ORDER BY `starttime` DESC LIMIT 1");
        $uptime = time() - $start_time;
    } else {
        // Get the result image arrow
        $res_img = 'Offline';
        $population = 0;
        $uptime = 0;
    }
    // Convert uptime into a days / hours / minutes format
    if ($uptime != 0) {
        $uptime = print_time(parse_time($uptime));
    } else {
        $uptime = "N/A";
    }
    // Setup this realm in the array
    $Realm[$i]['res_color'] = $res_color;
    $Realm[$i]['status'] = $res_img;
    $Realm[$i]['name'] = $result['name'];
    $Realm[$i]['type'] = $realm_type;
    $Realm[$i]['population'] = $population;
    $Realm[$i]['uptime'] = $uptime;
    // Unset the realms DB Connections
    unset($WDB_EXTRA);
    unset($CDB_EXTRA);
}
Пример #12
0
 public function parse_form_data($method = "post")
 {
     if ($method == "post") {
         $method = $_POST;
     }
     $messages = array();
     $self = $this;
     $set_end = false;
     $handlers = array("title" => function ($value) use(&$self, &$messages) {
         if (strlen($value) > 140) {
             $messages[] = "Title too long.";
         }
         $self->title = $value;
     }, "date1" => function ($value) use(&$self, &$messages) {
         $self->startdt = DateTime::createFromFormat("l j F Y", $value);
         if (!$self->startdt) {
             $self->startdt = DateTime::createFromFormat("Y-m-d", $value);
         }
         if (!$self->startdt) {
             $messages[] = "Invalid start date.";
         }
     }, "time1" => function ($value) use(&$self, &$messages) {
         $time = parse_time($value);
         if ($time['error_count'] > 0) {
             $messages[] = "Invalid start time.";
         }
         if ($self->startdt) {
             $self->startdt->setTime($time['hour'], $time['minute']);
         }
     }, "set_end" => function ($value) use(&$self, &$set_end) {
         $set_end = $value ? true : false;
     }, "date2" => function ($value) use(&$self, &$messages, &$set_end) {
         if ($value && $set_end) {
             $self->enddt = DateTime::createFromFormat("l j F Y", $value);
             if (!$self->enddt) {
                 $messages[] = "Invalid end date.";
             }
         } else {
             $self->enddt = NULL;
         }
     }, "time2" => function ($value) use(&$self, &$messages, &$set_end) {
         if ($value && $set_end) {
             $time = parse_time($value);
             if ($time['error_count'] > 0) {
                 $messages[] = "Invalid end time.";
             } else {
                 if ($self->enddt) {
                     $self->enddt->setTime($time['hour'], $time['minute']);
                 }
             }
         } else {
             $self->enddt = NULL;
         }
     }, "email" => function ($value) use(&$self, &$messages) {
         if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
             $messages[] = "Invalid email address";
         }
         $self->email = $value;
     }, "url" => function ($url) use(&$self, &$messages) {
         if (!$url || $url == "") {
             $self->url = NULL;
         } else {
             if (!preg_match('/^[a-zA-Z]+\\:/', $url)) {
                 $url = "http://" . $url;
             }
             if (!filter_var($url, FILTER_VALIDATE_URL)) {
                 $messages[] = "Invalid web address";
             }
         }
         $self->url = $url;
     }, "location" => function ($value) use(&$self, &$messages) {
         global $f3;
         $value = $f3->scrub($value);
         if (strlen($value) < 3) {
             $messages[] = "Location too short.";
         }
         $self->location = new Venue($value);
     }, "blurb" => function ($blurb) use(&$self, &$messages) {
         global $f3;
         $self->blurb = $f3->scrub($blurb);
     }, "film" => function ($film) use(&$self, &$messages) {
         $self->film = $film ? TRUE : FALSE;
     }, "host" => function ($host) use(&$self, &$messages) {
         global $f3;
         $self->host = $f3->scrub($host);
     });
     foreach ($handlers as $name => $handler) {
         $value = isset($method[$name]) ? $method[$name] : NULL;
         $handler($value);
     }
     if (isset($method['date2']) != isset($method['time2'])) {
         $messages[] = "Only one of end date / end time given.";
     }
     if (isset($method['free']) && $method['free'] == 'free') {
         $this->cost = NULL;
     } else {
         global $f3;
         $this->cost = $f3->scrub($method['cost']);
     }
     return $messages;
 }
/**
 * Input:                    Date Range:
 * 13.11.2006             -> 13.11.2006 - 14.11.2006 (exclusive)
 * 13.11.2006-15.11.2006  -> 13.11.2006 - 16.11.2006 (exclusive)
 * 15-11-2006-11/13/2006  -> 13.11.2006 - 16.11.2006 (exclusive)
 * >13.11.2006            -> 14.11.2006 - later
 * 13.11.2006-            -> 13.11.2006 - later
 * <13.11.2006            -> earlier    - 13.11.2006 (exclusive)
 * -13.11.2006            -> earlier    - 14.11.2006 (exclusive)
 */
function parse_date_range($date)
{
    $date_first = $date_last = FALSE;
    $_date_first = $_date_last = FALSE;
    $date_regex = '°((?:\\d{4}|\\d{1,2})(?:[./-]?\\d{1,2}[./-]?)(?:\\d{4}|\\d{1,2})?)(?:-((?:\\d{4}|\\d{1,2})(?:[./-]?\\d{1,2})?(?:[./-]?(?:\\d{4}|\\d{1,2}))?))?°';
    // Date range: < or > or -
    if (strpos(' <>-', $date[0])) {
        if (preg_match($date_regex, $date, $match) && isset($match[1]) && FALSE !== ($time1 = parse_time($match[1]))) {
            switch ($date[0]) {
                case '>':
                    $_date_first = $time1 + 86400;
                    break;
                case '-':
                    $_date_last = $time1 + 86400;
                    break;
                case '<':
                    $_date_last = $time1;
                    break;
            }
        }
    } else {
        if (!preg_match($date_regex, $date, $match) || !isset($match[1])) {
            return array($date_first, $date_last);
        }
        $time1 = parse_time($match[1]);
        if (isset($match[2]) && FALSE !== ($time2 = parse_time($match[2]))) {
            if (FALSE === $time1) {
                $_date_last = $time2 + 86400;
                // -13.11.2006
            } else {
                $_date_first = $time1;
                $_date_last = $time2;
                if ($time2 < $time1) {
                    list($_date_first, $_date_last) = array($_date_last, $_date_first);
                }
                $_date_last += 86400;
                // 13.11.2006-15.11.2006
            }
        } else {
            if (FALSE !== $time1) {
                // TODO: --date=3.2-
                if (strlen($date) == strlen($match[1]) || $date[strlen($match[1])] != '-') {
                    $_date_first = $time1;
                    $_date_last = $time1 + 86400;
                    // 13.11.2006
                } else {
                    $_date_first = $time1;
                    // 13.11.2006-
                }
            }
        }
    }
    return array($_date_first, $_date_last);
}
Пример #14
0
function parse_line_to_array($line)
{
    if (!is_numeric($line[0])) {
        return null;
    }
    DLOG("line1={$line}");
    $line = convert_seperator($line);
    DLOG("line2={$line}");
    $cells = explode("|", $line);
    $cells[0] = parse_time($cells[0]);
    $cells[2] = parse_amount($cells[2]);
    $cells[3] = parse_description($cells[3]);
    return $cells;
}
Пример #15
0
function check_date($x)
{
    if (is_bool($x) || is_int($x)) {
        return true;
    } else {
        if (is_string($x) && ($d = parse_time($x))) {
            return array(true, $d);
        } else {
            if (is_string($x)) {
                return array(false, "date parse error");
            } else {
                return false;
            }
        }
    }
}
Пример #16
0
                 <td width="0px" style="display: none;">' . $time . '</td>
                     </tr>';
     $folderJSArray .= "['img/ext/folder_small.gif', '" . sanitize($entry) . "', '" . _filemanager_folder . "', '" . $parsed_time . "'],\n";
     $folderNb++;
 } else {
     $entries_cnt++;
     $ext = substr(strrchr($entry, '.'), 1);
     if (is_array($MY_LIST_EXTENSIONS)) {
         if (!in_array(strtolower($ext), $MY_LIST_EXTENSIONS)) {
             continue;
         }
     }
     $size = filesize($absolutePath);
     $time = filemtime($absolutePath);
     $parsed_size = parse_size($size);
     $parsed_time = parse_time($time);
     $parsed_icon = 'img/ext/' . parse_icon($ext);
     $css_class = $ext . '_bg';
     #need to take img out and replace by css style
     # <td width="4%"><img src="'.$parsed_icon.'" width="16" height="16" border="0" alt="'.$entry.'" /></td>
     $t_files .= '<tr id="F' . $fileNb++ . '">
                     <td width="50%"><div  style="height:15px; overflow:hidden;"
                     					><a class="' . $css_class . '" href="javascript:;" onClick="javascript:fileSelected(\'' . $MY_BASE_URL . $relativePath . '\',\'' . $entry . '\',\'' . $parsed_icon . '\',\'' . $parsed_size . '\',\'' . $parsed_time . '\');">' . $entry . '</div></td>
                     <td width="18%" align="right">' . $parsed_size . '</td>
                     <td width="25%">' . $parsed_time . '</td>
                     <td width="0px" style="display: none;">' . $ext . '</td>
                     <td width="0px" style="display: none;">' . $size . '</td>
                     <td width="0px" style="display: none;">' . $time . '</td>
                     </tr>';
     $fileJSArray .= "['" . $parsed_icon . "', '" . sanitize($entry) . "', '" . $parsed_size . "', '" . $parsed_time . "'],\n";
 }
Пример #17
0
    $event->notice = get_request_variable('notice', 'no');
    $event->mark = get_request_variable('mark', 'no');
    $event->start_date = parse_date('{Y}-{m}-{d}', $start_date, false);
    if (!trim($stop_date)) {
        $stop_date = $start_date;
    }
    $event->stop_date = parse_date('{Y}-{m}-{d}', $stop_date, false);
    $wholeday = get_request_variable('wholeday', '');
    if ($wholeday) {
        $event->start_time = null;
        $event->stop_time = null;
    } else {
        $start_time = get_request_variable('start_time', date('H:i'));
        $event->start_time = parse_time('{H}:{i}', $start_time);
        $stop_time = get_request_variable('stop_time', date('H:i'));
        $event->stop_time = parse_time('{H}:{i}', $stop_time);
    }
    $errors = $event->IsValidData();
    if (count($errors) == 0) {
        $event->start_date = parse_date('{Y}-{m}-{d}', $start_date, true);
        $event->stop_date = parse_date('{Y}-{m}-{d}', $stop_date, true);
        $db->begin();
        $event->Save();
        $db->commit();
    }
}
if ($event->id_event == 0) {
    $event->start_date = $start_date;
    $event->stop_date = $stop_date;
}
$wholeday = $event->start_time == '';
Пример #18
0
}
?>


<?php 
foreach ($blog as $entry) {
    ?>

<?php 
    require_once ROOT . DS . '235' . DS . 'presentfunc.php';
    $e = stripslashes($entry['Entry']['entry']);
    //$e = nl2p_or_br($e);
    $ttl = stripslashes($entry['Entry']['title']);
    $l = make_url($entry['Entry']['id']);
    $date = parse_date($entry['Entry']['time']);
    $time = parse_time($entry['Entry']['time']);
    $tags = array();
    $tagInfo = count($entry['Tag']) > 0 ? $entry['Tag'] : '';
    if ($tagInfo) {
        foreach ($tagInfo as $tagInfo) {
            $tags[] = make_link($tagInfo['Tag']['tag_nm'], make_url('tag/' . $tagInfo['Tag']['tag_nm']));
        }
    }
    $cat = str_replace(" ", "_", $entry['Entry']['category']);
    // make it a kosher URL piece
    $c = make_link($entry['Entry']['category'], make_url('category/' . $cat));
    // when saving new category, do it in the javascript
    ?>

    <article class="entry" id="entry_<?php 
    echo $entry['Entry']['id'];