Exemple #1
0
switch ($phase) {
    case '1':
        $stocks = $doc->createElement('stocks');
        $stocks = $root->appendChild($stocks);
        $sql = "select symbol from stocks where enabled = 'Y'";
        $rows = mysql_query($sql);
        while ($cols = mysql_fetch_array($rows)) {
            $symbol = $cols['symbol'];
            addNode($doc, $stocks, 'symbol', $symbol);
        }
        $date = getorset('0', 'Last Process Date', '2007-06-13');
        if (isToday($date) == true) {
            $rc = '4';
            $message = 'The system is up-to-date. No processing is required.';
        } else {
            $date = getNextDay($date);
            addNode($doc, $stocks, 'nextdate', $date);
            if (isToday($date) == true) {
                if (isMarketOpen() == true) {
                    $rc = '4';
                    $message = 'The Stock Market is Still Open.';
                }
            }
        }
        break;
    case '2':
        // Get Price
        $symbol = $_GET[s];
        $date = $_GET[d];
        $price = getPrice($symbol, $date);
        if ($price == -1) {
Exemple #2
0
    $tag = $_GET['tag'];
    $monat = $_GET['monat'];
    $jahr = $_GET['jahr'];
    $timestamp = (int) mktime(0, 0, 0, $monat, $tag, $jahr);
} else {
    $timestamp = (int) time();
    $tag = (int) date("d", $timestamp);
    $monat = (int) date("m", $timestamp);
    $jahr = (int) date("Y", $timestamp);
}
echo "<ul id='timeunit'>";
echo "\t<li>" . getPreviousDay($tag, $monat, $jahr) . "</li>";
echo "\t<li class='active'><a href='tag.php'>Tag</a></li>";
echo "\t<li><a href='index.php'>Monat</a></li>";
echo "\t<li><a href='jahr.php'>Jahr</a></li>";
echo "\t<li>" . getNextDay($tag, $monat, $jahr) . "</li>";
echo "</ul>";
//oeffnet wrap
echo "<div id='wrap'>";
echo "     <div id='div_titel'>";
echo "<h1>" . $tag . "." . $monat . "." . $jahr . "</h1>";
echo "           <div id='untertitel'>";
echo "             <a href='belegungsformular.php'>Heersberg Online-Belegungskalender</a>";
echo "           </div>";
echo "     </div>";
$belegungen = array_merge(getDateCompleteDay($timestamp), getDatePreviousDay($timestamp), getDateFollowDay($timestamp), getDateActualDay($timestamp));
echo "<table class='datedetails datelist'>";
if (count($belegungen) != 0) {
    ?>
                <tr>
                    <th>Gruppe</th>
Exemple #3
0
function computeDatePermutations($begin, $end, $code)
{
    $MAX_NUM_DATES = 1000;
    if (!(fullDateValid($begin) && fullDateValid($end) && fullDateAlgorithmValid($code))) {
        return null;
    }
    $i = 0;
    $j = 0;
    $index = 0;
    $dow = 0;
    $tempList = explode(",", $code);
    $daysList = array();
    for ($i = 0; $i < 7; ++$i) {
        array_push($daysList, "");
    }
    $len = count($tempList);
    $len2 = count($daysList);
    for ($i = 0; $i < $len; ++$i) {
        $dow = substr($tempList[$i], 0, 1);
        if ($dow == "M") {
            $index = 0;
        } else {
            if ($dow == "T") {
                $index = 1;
            } else {
                if ($dow == "W") {
                    $index = 2;
                } else {
                    if ($dow == "R") {
                        $index = 3;
                    } else {
                        if ($dow == "F") {
                            $index = 4;
                        } else {
                            if ($dow == "S") {
                                $index = 5;
                            } else {
                                if ($dow == "U") {
                                    $index = 6;
                                } else {
                                    $index = -1;
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($index >= 0 && $index < $len2) {
            $daysList[$index] = substr($tempList[$i], 1, strlen($tempList[$i]));
        }
    }
    $len = count($daysList);
    for ($i = 0; $i < $len; ++$i) {
        $daysList[$i] = explode("|", $daysList[$i]);
        $len2 = count($daysList[$i]);
        if ($len2 > 0 && $daysList[$i][0] != null && $daysList[$i][0] != "") {
            for ($j = 0; $j < $len2; ++$j) {
                $daysList[$i][$j] = explode("-", $daysList[$i][$j]);
                $daysList[$i][$j][0] = timeValuesFromString($daysList[$i][$j][0]);
                $daysList[$i][$j][1] = timeValuesFromString($daysList[$i][$j][1]);
                //echo print_r($daysList[$i][$j][0])." & ".print_r($daysList[$i][$j][1])."\n";
            }
        }
    }
    $children = array();
    $beginDate = dateFromString($begin);
    $endDate = dateFromString($end);
    $time = null;
    $temp = null;
    $start = null;
    $stop = null;
    $beginTime = $beginDate;
    $endTime = $endDate;
    $time = $beginTime;
    // DO A ROUGH CALCULATION TO DETERMINE HOW MANY WILL BE GENERATED - end-start years * weeks * M,T,W,R,F,S,U
    //echo "START TIME: (".stringFromDate($time).")\n";
    //echo "END   TIME: (".stringFromDate($endTime).")\n";
    $count = 0;
    while ($time < $endTime && $count < 10000) {
        // for each day
        $dow = intval(date("w", $time));
        if ($dow == 1) {
            // monday
            $index = 0;
        } else {
            if ($dow == 2) {
                $index = 1;
            } else {
                if ($dow == 3) {
                    $index = 2;
                } else {
                    if ($dow == 4) {
                        $index = 3;
                    } else {
                        if ($dow == 5) {
                            $index = 4;
                        } else {
                            if ($dow == 6) {
                                $index = 5;
                            } else {
                                if ($dow == 0) {
                                    // sunday
                                    $index = 6;
                                }
                            }
                        }
                    }
                }
            }
        }
        $len = count($daysList[$index]);
        if ($len > 0 && $daysList[$index][0] != null && $daysList[$index][0] != "") {
            for ($i = 0; $i < $len; ++$i) {
                // start/stop list
                $j = 0;
                // $seconds,$yea,$mon,$day,$hou,$min,$sec,$nano
                $start = addTimeToSeconds($time, 0, 0, 0, intval($daysList[$index][$i][$j][0]), intval($daysList[$index][$i][$j][1]), intval($daysList[$index][$i][$j][2]), intval($daysList[$index][$i][$j][3]));
                $j = 1;
                $stop = addTimeToSeconds($start, 0, 0, 0, intval($daysList[$index][$i][$j][0]), intval($daysList[$index][$i][$j][1]), intval($daysList[$index][$i][$j][2]), intval($daysList[$index][$i][$j][3]));
                array_push($children, array($start, $stop));
                if (count($children) >= $MAX_NUM_DATES) {
                    return null;
                }
            }
        }
        $time = getNextDay($time);
        //echo "TIME: (".stringFromDate($time).")\n";
        ++$count;
    }
    return $children;
}