예제 #1
0
function systemColorBuild($red, $green, $blue)
{
    if ($red < 0) {
        $red = 0;
    }
    if ($green < 0) {
        $green = 0;
    }
    if ($blue < 0) {
        $blue = 0;
    }
    if ($red > 255) {
        $red = 255;
    }
    if ($green > 255) {
        $green = 255;
    }
    if ($blue > 255) {
        $blue = 255;
    }
    $red = STR_PAD(dechex($red), 2, "0", STR_PAD_LEFT);
    $green = STR_PAD(dechex($green), 2, "0", STR_PAD_LEFT);
    $blue = STR_PAD(dechex($blue), 2, "0", STR_PAD_LEFT);
    $color = strtoupper($red . $green . $blue);
    // $color = strtoupper($red . $red . $red);
    return $color;
}
예제 #2
0
function sec2hms($sec, $padHours = FALSE)
{
    $hours_min_secs = "";
    $hours = INTVAL(INTVAL($sec) / 3600);
    $hours_min_secs .= $padHours ? STR_PAD($hours, 2, "0", STR_PAD_LEFT) . ':' : $hours . ':';
    $minutes = INTVAL($sec / 60 % 60);
    $hours_min_secs .= STR_PAD($minutes, 2, "0", STR_PAD_LEFT) . ':';
    $seconds = INTVAL($sec % 60);
    $hours_min_secs .= STR_PAD($seconds, 2, "0", STR_PAD_LEFT);
    return $hours_min_secs;
}
예제 #3
0
 function show_calendar($startyear, $startmonth, $property_id, $excludestatus = array('draft'), $bookedclass = 'booked', $holdingdiv = true)
 {
     $start = strtotime("{$startyear}-{$startmonth}-1");
     $dom = 1;
     //$year, $month, $prepostpack = false, $property_id = false, $excludestatus = array('draft')
     $bookings = $this->booking->get_montharray($startyear, $startmonth, true, $property_id, $excludestatus);
     if ($holdingdiv) {
         echo "<div class='month'>\n";
     }
     echo "<h4 class='monthname'>";
     echo "<span class='name'>" . strftime('%B %Y', $start) . "</span>";
     echo "</h4>";
     $startingday = (int) strftime('%w', $start);
     echo "<ul class='monthdetails'>\n";
     // Day of week headings
     $wbeg = strtotime('-' . $startingday . ' days', $start);
     echo "<li class='weekheadings'>";
     echo "<ul class='dow'>";
     for ($n = 0; $n < 7; $n++) {
         $wday = strtotime('+' . $n . ' days', $wbeg);
         echo "<li>" . substr(strftime('%a', $wday), 0, 1) . "</li>";
     }
     echo "</ul>";
     echo "</li>";
     echo "<li class='weekrow'>";
     echo "<ul>";
     for ($n = 0; $n < $startingday; $n++) {
         echo "<li class='middle'>&nbsp;</li>";
     }
     for ($n = $startingday; $n < 7; $n++) {
         if ($n != 6) {
             $class = "middle";
         } else {
             $class = '';
         }
         if (isset($bookings[$startyear . STR_PAD($startmonth, 2, "0", STR_PAD_LEFT) . STR_PAD($dom, 2, "0", STR_PAD_LEFT)])) {
             //echo $startyear . STR_PAD($startmonth, 2 , "0", STR_PAD_LEFT) . STR_PAD($dom, 2 , "0", STR_PAD_LEFT);
             $class .= " " . $bookedclass;
             $yesterday = strtotime('-1 day', strtotime($startyear . '-' . $startmonth . '-' . $dom));
             if (!isset($bookings[date("Ymd", $yesterday)])) {
                 $class .= " startday";
             }
             $tomorrow = strtotime('+1 day', strtotime($startyear . '-' . $startmonth . '-' . $dom));
             if (!isset($bookings[date("Ymd", $tomorrow)])) {
                 $class .= " endday";
             }
         }
         echo "<li class='{$class}' style='{$style}'>";
         echo $dom++;
         echo "</li>";
     }
     echo "</ul>";
     echo "</li> <!-- weekrow -->\n";
     $dow = 0;
     for ($n = $dom; $n <= date('t', $start); $n++) {
         if ($dow == 0) {
             echo "<li class='weekrow'>\n";
             echo "<ul>\n";
         }
         if ($dow != 6) {
             $class = "middle";
         } else {
             $class = '';
         }
         if (isset($bookings[$startyear . STR_PAD($startmonth, 2, "0", STR_PAD_LEFT) . STR_PAD($n, 2, "0", STR_PAD_LEFT)])) {
             //echo $startyear . STR_PAD($startmonth, 2 , "0", STR_PAD_LEFT) . STR_PAD($dom, 2 , "0", STR_PAD_LEFT);
             $class .= " " . $bookedclass;
             $yesterday = strtotime('-1 day', strtotime($startyear . '-' . $startmonth . '-' . $n));
             if (!isset($bookings[date("Ymd", $yesterday)])) {
                 $class .= " startday";
             }
             $tomorrow = strtotime('+1 day', strtotime($startyear . '-' . $startmonth . '-' . $n));
             if (!isset($bookings[date("Ymd", $tomorrow)])) {
                 $class .= " endday";
             }
         }
         $dow++;
         echo "<li class='{$class}' style='{$style}'>";
         echo $n;
         echo "</li>";
         if ($dow == 7 && $n != date('t', $start)) {
             echo "</ul>\n";
             echo "</li> <!-- weekrow -->\n";
             $dow = 0;
         }
     }
     // Finish off the last week with blank days
     // find the day we are on to co
     for ($n = $dow; $n < 7; $n++) {
         if ($n != 6) {
             echo "<li class='middle'>&nbsp;</li>";
         } else {
             echo "<li>&nbsp;</li>";
         }
     }
     echo "</ul> <!-- month details -->\n";
     if ($holdingdiv) {
         echo "</div> <!-- month -->\n";
     }
 }
예제 #4
0
파일: delete.php 프로젝트: O-R-G/o-r-g.com
    //  Display warning
    ?>
	<div class='monoHvy'>WARNING!<br />You are about to permanently delete this object.<br/>If this object is linked, the original will not be deleted.</div>
	<?php 
    $l = 0;
    if ($k) {
        $numrows = $k;
        $padout = floor(log10($numrows)) + 1;
        if ($padout < 2) {
            $padout = 2;
        }
        echo "\nThe following " . $k . " objects will also be deleted as a result: <br /><br />";
        for ($i = 0; $i < $j; $i++) {
            $l++;
            if ($connectedAll[$i]["dependent"] == TRUE) {
                echo "\n" . STR_PAD($l, $padout, "0", STR_PAD_LEFT) . " <a href='" . $dbAdmin . "browse.php" . urlData() . "," . $connectedAll[$i]["id"] . "'>" . strip_tags($connectedAll[$i]["name"]) . "</a><br />";
            }
        }
    }
    ?>
<br /><br />
	<form action="<?php 
    echo $PHP_SELF . urlData();
    ?>
" method="post" style="padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px;">
	<input name='action' type='hidden' value='delete' />
	<input name='cancel' type='button' value='Cancel' onClick="javascript:history.back();" /> 
	<input name='submit' type='submit' value='Delete Object' />
	</form><br />&nbsp;
	<?php 
} else {
 function show_calendar($startyear, $startmonth, $holdingdiv = true)
 {
     global $filterstartday;
     if (!empty($filterstartday)) {
         if ($startyear == date('Y', (int) $filterstartday) && $startmonth == date('n', (int) $filterstartday)) {
             $selday = date('j', (int) $filterstartday);
         } else {
             $selday = 0;
         }
     } else {
         $selday = 0;
     }
     if ($startmonth == date('n') && $startyear == date('Y')) {
         $today = date('j');
         if ($selday == 0) {
             $selday = $today;
         }
     } else {
         $today = 0;
     }
     $start = strtotime("{$startyear}-{$startmonth}-1");
     $dom = 1;
     $bookings = $this->booking->get_montharray($startyear, $startmonth, false, false, false);
     if ($holdingdiv) {
         echo "<div class='month'>\n";
     }
     echo "<h4 class='monthname'>";
     echo "<a href='#prevmonth' class='previousmonth' id='" . date("Y-n", strtotime('-1 month', $start)) . "'>&nbsp;</a>";
     echo "<span class='name'>" . strftime('%B %Y', $start) . "</span>";
     echo "<a href='#nextmonth' class='nextmonth' id='" . date("Y-n", strtotime('+1 month', $start)) . "'>&nbsp;</a>";
     echo "</h4>";
     $startingday = (int) strftime('%w', $start);
     echo "<ul class='monthdetails'>\n";
     // Day of week headings
     $wbeg = strtotime('-' . $startingday . ' days', $start);
     echo "<li class='weekheadings'>";
     echo "<ul class='dow'>";
     for ($n = 0; $n < 7; $n++) {
         $wday = strtotime('+' . $n . ' days', $wbeg);
         echo "<li>" . substr(strftime('%a', $wday), 0, 1) . "</li>";
     }
     echo "</ul>";
     echo "</li>";
     echo "<li class='weekrow'>";
     echo "<ul>";
     for ($n = 0; $n < $startingday; $n++) {
         echo "<li class='middle'>&nbsp;</li>";
     }
     for ($n = $startingday; $n < 7; $n++) {
         if ($n != 6) {
             $class = "middle";
         } else {
             $class = '';
         }
         if ($selday == $dom) {
             $class .= " selday";
         }
         if ($today == $dom) {
             $class .= " today";
         }
         if (isset($bookings[$startyear . STR_PAD($startmonth, 2, "0", STR_PAD_LEFT) . STR_PAD($dom, 2, "0", STR_PAD_LEFT)])) {
             //echo $startyear . STR_PAD($startmonth, 2 , "0", STR_PAD_LEFT) . STR_PAD($dom, 2 , "0", STR_PAD_LEFT);
             switch ($bookings[$startyear . STR_PAD($startmonth, 2, "0", STR_PAD_LEFT) . STR_PAD($dom, 2, "0", STR_PAD_LEFT)]) {
                 case 1:
                     $mark = 1;
                     break;
                 case 2:
                     $mark = 2;
                     break;
                 case 3:
                     $mark = 3;
                     break;
                 case 4:
                     $mark = 4;
                     break;
                 default:
                     $mark = 4;
             }
             $mark = "<div class='booked booked-" . $mark . "'></div>";
         } else {
             $mark = '';
         }
         echo "<li class='{$class}'>";
         echo "<a href='" . add_query_arg(array("filterstartday" => strtotime("{$startyear}-{$startmonth}-{$dom}")), remove_query_arg('paged')) . "'>";
         echo $dom++;
         echo "</a>";
         echo $mark;
         echo "</li>";
     }
     echo "</ul>";
     echo "</li> <!-- weekrow -->\n";
     $dow = 0;
     for ($n = $dom; $n <= date('t', $start); $n++) {
         if ($dow == 0) {
             echo "<li class='weekrow'>\n";
             echo "<ul>\n";
         }
         if ($dow != 6) {
             $class = "middle";
         } else {
             $class = '';
         }
         if ($selday == $n) {
             $class .= " selday";
         }
         if ($today == $n) {
             $class .= " today";
         }
         if (isset($bookings[$startyear . STR_PAD($startmonth, 2, "0", STR_PAD_LEFT) . STR_PAD($n, 2, "0", STR_PAD_LEFT)])) {
             //echo $startyear . STR_PAD($startmonth, 2 , "0", STR_PAD_LEFT) . STR_PAD($dom, 2 , "0", STR_PAD_LEFT);
             switch ($bookings[$startyear . STR_PAD($startmonth, 2, "0", STR_PAD_LEFT) . STR_PAD($n, 2, "0", STR_PAD_LEFT)]) {
                 case 1:
                     $mark = 1;
                     break;
                 case 2:
                     $mark = 2;
                     break;
                 case 3:
                     $mark = 3;
                     break;
                 case 4:
                     $mark = 4;
                     break;
                 default:
                     $mark = 4;
             }
             $mark = "<div class='booked booked-" . $mark . "'></div>";
         } else {
             $mark = '';
         }
         $dow++;
         echo "<li class='{$class}'>";
         echo "<a href='" . add_query_arg(array("filterstartday" => strtotime("{$startyear}-{$startmonth}-{$n}")), remove_query_arg('paged')) . "'>";
         echo $n;
         echo "</a>";
         echo $mark;
         echo "</li>";
         if ($dow == 7 && $n != date('t', $start)) {
             echo "</ul>\n";
             echo "</li> <!-- weekrow -->\n";
             $dow = 0;
         }
     }
     // Finish off the last week with blank days
     // find the day we are on to co
     for ($n = $dow; $n < 7; $n++) {
         if ($n != 6) {
             echo "<li class='middle'>&nbsp;</li>";
         } else {
             echo "<li>&nbsp;</li>";
         }
     }
     echo "</ul> <!-- month details -->\n";
     if ($holdingdiv) {
         echo "</div> <!-- month -->\n";
     }
 }
예제 #6
0
파일: browse.php 프로젝트: O-R-G/o-r-g.com
require_once "GLOBAL/head.php";
////////////////////////
//  Attached Objects  //
////////////////////////
//  Get attached objects (if any)
$sql = "SELECT *, objects.id AS objectsId FROM objects, wires WHERE wires.fromid = '" . $objects[$o] . "' AND wires.toid = objects.id AND wires.active = '1' AND objects.active = '1' ORDER BY weight DESC, objects.rank, end DESC, begin DESC, name1, name2, objects.modified DESC, objects.created DESC";
$result = MYSQL_QUERY($sql);
$numrows = MYSQL_NUM_ROWS($result);
$padout = floor(log10($numrows)) + 1;
if ($padout < 2) {
    $padout = 2;
}
$i = 1;
$myrow["id"] = $myrow["objectsId"];
while ($myrow = MYSQL_FETCH_ARRAY($result)) {
    $name = $myrow["name1"];
    if ($myrow["name2"]) {
        $name .= " " . $myrow["name2"];
    }
    if (strlen($name) > 60) {
        $name = substr($name, 0, 60) . "...";
    }
    echo STR_PAD($i++, $padout, "0", STR_PAD_LEFT) . " " . "\n<a href='" . $dbAdmin . "browse.php" . urlData();
    if (sizeof($objects)) {
        echo ",";
    }
    echo $myrow["objectsId"] . "'>";
    echo strip_tags($name) . "</a><br />";
}
echo "\n<br /><br />\n<a href='add.php" . urlData() . "'>ADD OBJECT...</a>&nbsp;<a href='link.php" . urlData() . "'>LINK ...</a><br />";
require_once "GLOBAL/foot.php";
예제 #7
0
 function RepStandard()
 {
     // First Generate the query
     $sq = $this->RepStandardQuery();
     if ($this->display == 'SQL') {
         echo "<h1>The Generated SQL</h1>";
         hprint_r($sq);
         return;
     }
     // Now execute the query and run the report
     if ($this->display == 'CSV') {
         echo "<pre>";
         echo implode(',', $this->Cols) . "\n";
         $res = SQL($sq);
         while ($row = pg_fetch_row($res)) {
             echo implode(',', $row) . "\n";
         }
         echo "</pre>";
         return;
     }
     // Pull the info on breaking, sums, etc.
     $srep = SQLFC($this->report_id);
     $s2 = "SELECT rcl.column_id,rcl.reportlevel,rcl.summact\n             FROM reportcollevels rcl\n             JOIN reportcolumns   rc  ON rcl.column_id = rc.column_id\n            WHERE rc.report = {$srep}\n            ORDER BY rcl.reportlevel,rc.uicolseq";
     $breaks = SQL_AllRows($s2);
     $abreaks = array();
     foreach ($breaks as $break) {
         if ($break['summact'] == 'BREAK') {
             $abreaks[$break['reportlevel']]['breaks'][$break['column_id']] = '';
         } else {
             $abreaks[$break['reportlevel']]['data'][$break['column_id']] = array('summact' => $break['summact'], 'val' => 0, 'cnt' => 0);
         }
     }
     // There is always some setup, for either PDF or HTML, so do that
     // here.
     $this->RepHeader();
     // Now execute the query and run the report
     $res = SQL($sq);
     $firstrow = true;
     while ($row = SQL_Fetch_Array($res)) {
         if ($firstrow) {
             $firstrow = false;
             $this->RepStandardBreakLevelsInit($abreaks, $row);
         } else {
             $this->RepStandardBreakLevels($abreaks, $row);
         }
         $xpos = 0;
         foreach ($this->rows_col as $column_id => $colinfo) {
             $disp = substr($row[$column_id], 0, $colinfo['dispsize']);
             $disp = STR_PAD($disp, $colinfo['dispsize'], ' ');
             $this->PlaceCell($xpos, $disp);
             $xpos += 2 + $colinfo['dispsize'];
         }
         $this->ehFlushLine();
         $this->RepStandardRowsToLevels($abreaks, $row);
     }
     $this->RepStandardBreakLevels($abreaks, $row, true);
     // There is always some cleanup, either PDF or HTML
     $this->RepFooter();
 }
예제 #8
0
파일: Order.php 프로젝트: sofiananny/root
 function validate()
 {
     unset($_SESSION['order']['err']);
     $response['success'] = $_SESSION['order']['valid'] = false;
     $response['order_prop'] = $response['pay_prop'] = '';
     $errors = array();
     $uppercase = array('number' => '', 'building' => '', 'gate' => '', 'floor' => '', 'apartment' => '', 'dds' => '');
     if (empty($_POST)) {
         $response['step'] = 4;
     } else {
         $response['step'] = $_POST['step'];
         foreach ($_POST as $key => $val) {
             if (isset($uppercase[$key])) {
                 $_SESSION['order'][$key] = mb_strtoupper(trim($val), "utf-8");
             } else {
                 $_SESSION['order'][$key] = trim($val);
             }
         }
         if (isset($_POST['invoice'])) {
             $_SESSION['order']['invoice'] = 1;
         } else {
             $_SESSION['order']['invoice'] = 0;
         }
     }
     // Валидация стъпка 1 адрес ************************************************
     if (!$_SESSION['order']['district']) {
         $errors[] = 'district';
     }
     if (!($_SESSION['order']['street'] . $_SESSION['order']['building'])) {
         $errors[] = 'street';
         $errors[] = 'building';
     }
     if ($_SESSION['order']['street'] && !$_SESSION['order']['number']) {
         $errors[] = 'number';
     }
     if ($_SESSION['order']['building']) {
         if (!$_SESSION['order']['gate']) {
             $errors[] = 'gate';
         }
         if (!$_SESSION['order']['apartment']) {
             $errors[] = 'apartment';
         }
     }
     if (!empty($errors)) {
         $response['step'] = 1;
     }
     // *************************************************************************
     if ($response['step'] > 2) {
         // Валидация стъпка 2 дата,час,продължителност **
         $dt = $_SESSION['order']['date'];
         $tm = $_SESSION['order']['time'];
         if (!(strlen($dt) == 10 && checkdate(substr($dt, 3, 2), substr($dt, 0, 2), substr($dt, 6, 4)))) {
             $errors[] = 'date';
         }
         if (!preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $tm)) {
             $errors[] = 'time';
         }
         if (!$_SESSION['order']['duration']) {
             $errors[] = 'duration';
         }
         if (!$_SESSION['order']['kids_count']) {
             $errors[] = 'kids_count';
         }
         /*else
             {
               for($i = 0; $i < $_SESSION['order']['kids_count']; $i++)
               {
                 if(!$_SESSION['order']['kid_name[$i]']) 
                 {
                   $errors[]='kid_name[$i]';
                 } 
                 if(!$_SESSION['order']['kid_age[$i]']) 
                 {
                   $errors[]='kid_age[$i]';
                 }       
               }
             }
           */
         if (!empty($errors)) {
             $response['step'] = 2;
         } else {
             $this->calc_price();
         }
     }
     // ***********************************************************************
     $total = $_SESSION['order']['price'] + $_SESSION['order']['taxi'];
     $response['price'] = (int) $total;
     $response['supprice'] = STR_PAD(round($total * 100 - $response['price'] * 100), 2, "0", STR_PAD_LEFT);
     if ($response['step'] > 3) {
         // Валидация стъпка 3 ***************************
         // if (!$_SESSION['order']['first_nanny_id']) {
         //   $errors[]='select_first_nanny';
         // }
         // if (!$_SESSION['order']['second_nanny_id']) {
         //   $errors[]='select_second_nanny';
         // }
         if (!empty($errors)) {
             $response['step'] = 3;
         } else {
             // Генериране на данни за стъпка 4 ********************************
             $_SESSION['order']['valid'] = true;
             $adr = "<label class='data-label'>гр.София</label><br/>кв. <label class='data-label'>";
             $query = $this->db->get_where('districts', array('dist_id' => $_SESSION['order']['district']));
             $adr .= $query->row('dist_name') . "</label><br/>";
             foreach ($_SESSION['order'] as $key => $v) {
                 if (trim($v)) {
                     $s = "";
                     switch ($key) {
                         case 'street':
                             $l = "бул./ул.";
                             break;
                         case 'number':
                             $l = "No.";
                             break;
                         case 'building':
                             $l = "бл.";
                             break;
                         case 'gate':
                             $l = "вх.";
                             break;
                         case 'floor':
                             $l = "ет.";
                             break;
                         case 'apartment':
                             $l = "ап.";
                             break;
                         default:
                             $l = "";
                     }
                     if ($l) {
                         $adr .= $l . " <label class='data-label'>" . $_SESSION['order'][$key] . " &nbsp;</label>" . $s;
                     }
                 }
             }
             $response['order_prop'] = "<center><h4>Адрес</h4></center><div class='order_prop'>" . $adr;
             if ($_SESSION['order']['note']) {
                 $response['order_prop'] .= "</br></br><label class='control-label'>Допълнително описание</label><br/>\n            <textarea class='form-control data-label' style='resize: none;' readonly>" . $_SESSION['order']['note'] . "</textarea>";
             }
             $response['order_prop'] .= "</div><center><h4>Дата и час</h4></center><div class='prder_prop'>Дата\n          <label class='data-label'>" . $_SESSION['order']['date'] . "</label> г. &nbsp; - от &nbsp;<label class='data-label'>" . $_SESSION['order']['time'] . "</label> &nbsp; - до &nbsp;<label class='data-label'>" . date('H:i', strtotime($_SESSION['order']['time'] . "+" . $_SESSION['order']['duration'] . "hours")) . "</label>&nbsp; часа</div>";
             $response['pay_prop'] = "<center style='margin-bottom: 20px; background-color: #F8F8F8; padding: 5px;'><h2>\n          Цена &nbsp; <label id='cprice'>{$response['price']}</label> <sup><sup id='csupprice'>{$response['supprice']}</sup></sup>\n          лв.</h2></center>";
         }
         // *********************************************************************
     }
     $cyrillic = $i = 0;
     $exceptions = array('date' => '', 'time' => '', 'invoice' => '', 'dds' => '');
     foreach ($_SESSION['order'] as $key => $val) {
         $i++;
         if (!isset($exceptions[$key]) && !preg_match("/(*UTF8)^[А-Яа-я0-9 &.,\"\r\n-]*\$/", $val)) {
             if ($i < 10 || $_SESSION['order']['invoice'] && $response['step'] > 2) {
                 $errors[] = $key;
                 if (!$cyrillic) {
                     $cyrillic = $i;
                 }
             }
         }
     }
     if ($cyrillic) {
         $errors[] = 'cyrillic';
         if ($cyrillic < 10 && $response['step'] > 1) {
             $response['step'] = 1;
         }
         if ($cyrillic > 10 && $response['step'] > 3) {
             $response['step'] = 3;
         }
     }
     if (empty($errors)) {
         $response['success'] = true;
     } else {
         $response['errors'] = $errors;
     }
     if (empty($errors)) {
         $response['success'] = true;
     } else {
         $response['errors'] = $errors;
     }
     header('Content-Type: application/json');
     echo json_encode($response);
 }