예제 #1
0
파일: 1.php 프로젝트: nsegreto/fuze
<?php

// Formatted as: ("email":"email_value", "name":"name_value", ...)
$invarr[] = array("email" => "*****@*****.**", "name" => "Nino S");
$invarr[] = array("email" => "*****@*****.**", "name" => "Tony S");
$invstr = json_encode($invarr);
dumpit($invarr);
prtit($invstr);
function prtit($msg)
{
    echo "\n\t{$msg}\n";
}
function dumpit($obj)
{
    echo "\n\t";
    var_dump($obj);
    echo "\n";
}
예제 #2
0
/** easier to read caller-chain */
function dump_call_trace()
{
    $s = '';
    $traceArr = debug_backtrace();
    array_shift($traceArr);
    $tabs = sizeof($traceArr) - 1;
    foreach ($traceArr as $arr) {
        for ($i = 0; $i < $tabs; $i++) {
            $s .= ' ';
        }
        $tabs -= 1;
        if (isset($arr['class'])) {
            $s .= $arr['class'] . '.';
        }
        $args = array();
        if (!empty($arr['args'])) {
            foreach ($arr['args'] as $v) {
                if (is_null($v)) {
                    $args[] = 'null';
                } else {
                    if (is_array($v)) {
                        $args[] = 'Array[' . sizeof($v) . ']';
                    } else {
                        if (is_object($v)) {
                            $args[] = 'Object:' . get_class($v);
                        } else {
                            if (is_bool($v)) {
                                $args[] = $v ? 'true' : 'false';
                            } else {
                                $v = (string) @$v;
                                $args[] = "\"" . $str . "\"";
                            }
                        }
                    }
                }
            }
        }
        $s .= $arr['function'] . '(' . implode(', ', $args) . ')';
        $Line = isset($arr['line']) ? $arr['line'] : "unknown";
        $File = isset($arr['file']) ? $arr['file'] : "unknown";
        $s .= sprintf(" # line %4d, file: %s", $Line, $File);
        $s .= "\n";
    }
    return dumpit($s);
}
예제 #3
0
function ProcessCorrectionFile($filename)
{
    $loc = 'readerlib.php=>ProcessLogFile';
    $file = fopen($filename, "r");
    if ($file === false) {
        $error_msg = "Unable to open file.";
        return false;
    }
    $ln = 1;
    $ncorrections = 0;
    $nbad = 0;
    // The first line is the column headers.
    $header = fgetcsv($file);
    $ln++;
    if ($header === false) {
        $m = 'No header for input corrections file, line ' . $ln;
        log_msg($loc, $m);
        echo $m . "<br>";
        return false;
    }
    // Trim the header values...
    $hh = array();
    foreach ($header as $h) {
        $hh[] = trim($h);
    }
    $header = $hh;
    // Now, do some sanity checks to make sure we have
    // an appropriate file.
    if (!in_array("Action", $header) || !in_array("BadgeID", $header) || !in_array("T0", $header) || !in_array("Reason", $header)) {
        dumpit($header);
        $m = "Invalid columns for correction file, line " . $ln;
        log_msg($loc, $m);
        echo $m . "<br>";
        return false;
    }
    while (true) {
        $data = fgetcsv($file);
        $ln++;
        if ($data === false) {
            break;
        }
        // Don't process blank lines.
        if (count($data) <= 0) {
            continue;
        }
        if (is_null($data[0])) {
            continue;
        }
        // Organize the data into an associtive array
        $fields = JoinKeyValues($header, $data);
        // Make sure we have required data
        if (!isset($fields["Action"]) || !isset($fields["BadgeID"]) || !isset($fields["T0"])) {
            $m = 'Required data not found in correction file, line ' . $ln;
            log_msg($loc, $m);
            echo $m . "<br>";
            $nbad++;
            continue;
        }
        $action = $fields["Action"];
        $badgeid = strtolower($fields["BadgeID"]);
        if (isset($fields["Reason"])) {
            $reason = $fields["Reason"];
        } else {
            $reason = "(Unknown)";
        }
        // Make sure T0 is a valid time between 2000 and 2030.
        $tme = strtotime($fields["T0"]);
        if ($tme === false) {
            $nbad++;
            continue;
        }
        $d0 = strtotime("2000-01-01");
        $d1 = strtotime("2030-01-01");
        if ($tme < $d0 || $tme > $d1) {
            $nbad++;
            continue;
        }
        // Okay, store the record.
        AddCorrection($action, $badgeid, date("Y-m-d H:i:s", $tme), $reason);
        $ncorrections++;
    }
    return array($ln, $ncorrections, $nbad);
}
예제 #4
0
//
// Created: 12/29/14 DLB
// --------------------------------------------------------------------
require_once "libs/all.php";
session_start();
log_page();
$timer = new Timer();
$loc = "t.php";
include "forms/header.php";
include "forms/navform.php";
echo '<div class="content_area">';
//AddCorrection("DeleteScan", "*", "2015-01-03 10:00:00", "Just Testing.");
$a = array(array("name" => "Dal", "age" => 58), array("name" => "Keith", "age" => 55), array("name" => "Gail", "age" => 53));
dumpit($a);
usort($a, "dcmp");
dumpit($a);
function dcmp($a, $b)
{
    if ($a["age"] == $b["age"]) {
        return 0;
    }
    if ($a["age"] > $b["age"]) {
        return 1;
    } else {
        return -1;
    }
}
//dumpit(CalculateAllScores());
//dumpit(CalculateScoreForOne("a004"));
//dumpit(GetLastDayForAttendance());
//$lastday = "1/14/2015";
예제 #5
0
function CreateNewWorkOrder($data)
{
    $loc = rmabs(__FILE__ . ".CreateNewWorkOrder");
    DenyGuest();
    // Don't allow Guests to do this...
    if (empty($data["Title"])) {
        return array(0, "Title cannot be empty.");
    }
    if (empty($data["Description"])) {
        return array(0, "Title cannot be empty.");
    }
    if (empty($data["Priority"])) {
        return array(0, "Priority cannot be empty.");
    }
    if (empty($data["Project"])) {
        return array(0, "Project cannot be empty.");
    }
    if (empty($data["Requestor"])) {
        return array(0, "Requestor cannot be empty.");
    }
    if (empty($data["Receiver"])) {
        return array(0, "Receiver cannot be empty.");
    }
    if (empty($data["DateNeedBy"])) {
        return array(0, "DateNeedBy cannot be empty.");
    }
    if (empty($data["DateCreated"])) {
        return array(0, "DateCreated cannot be empty.");
    }
    if (!isset($data["Active"])) {
        $data["Active"] = 1;
    }
    // Check for duplicate title.
    $sql = 'SELECT WID FROM WorkOrders WHERE Title=?';
    $args = array($data["Title"]);
    $stmt = SqlPrepareAndExectue($loc, $sql, $args);
    $stmt->bind_result($arg_out_wid);
    $nr = 0;
    while ($stmt->fetch()) {
        $nr++;
    }
    $stmt->close();
    if ($nr > 0) {
        $msg = 'Unable to create Work Order. Duplicate Title. ';
        log_msg($loc, $msg);
        return array(0, $msg);
    }
    $sql = 'INSERT INTO WorkOrders ' . '(Title, Description, Priority, Project, Revision, ' . 'Requestor, Receiver, AuthorID, DateCreated, DateNeedBy, ' . 'Assigned, Approved, ApprovedByCap, Finished, Closed, Active) ';
    $sql .= ' VALUES(';
    $sql .= '  ?';
    // . $data["Title"] . '"';
    $sql .= ', ?';
    // . $data["Description"] . '"';
    $sql .= ', ?';
    // . $data["Priority"] . '"';
    $sql .= ', ?';
    // . $data["Project"] . '"';
    $sql .= ', ' . intval($data["Revision"]);
    $sql .= ', ?';
    // . $data["Requestor"] . '"';
    $sql .= ', ?';
    // . $data["Receiver"] . '"';
    $sql .= ', ' . intval($data["AuthorID"]);
    $sql .= ', "' . $data["DateCreated"] . '"';
    $sql .= ', "' . $data["DateNeedBy"] . '"';
    $sql .= ', ' . TFstr($data["Assigned"]);
    $sql .= ', ' . TFstr($data["Approved"]);
    $sql .= ', ' . TFstr($data["ApprovedByCap"]);
    $sql .= ', ' . TFstr($data["Finished"]);
    $sql .= ', ' . TFstr($data["Closed"]);
    $sql .= ', ' . TFstr($data["Active"]);
    $sql .= ')';
    $title = $data["Title"];
    $args = array($data["Title"], $data["Description"], $data["Priority"], $data["Project"], $data["Requestor"], $data["Receiver"]);
    $stmt = SqlPrepareAndExectue($loc, $sql, $args);
    $stmt->close();
    log_msg($loc, array("New WO added!  Title=" . $data["Title"], "AuthorID= " . $data["AuthorID"]));
    // Quicky find the new WO
    $sql = 'Select WID, Revision From WorkOrders WHERE Title = ?';
    $args = array($data["Title"]);
    $stmt = SqlPrepareAndExectue($loc, $sql, $args);
    $stmt->bind_result($arg_out_wid, $arg_out_revision);
    $nr = 0;
    $rows = array();
    while ($stmt->fetch()) {
        $row["WID"] = $arg_out_wid;
        $row["Revision"] = $arg_out_revision;
        $rows[] = $row;
        $nr++;
    }
    if ($nr != 1) {
        //DieWithMsg($loc, array('Unable to find newly create workorder.', 'SQL=' . $sql));
        dumpit($args);
    }
    $row = $rows[0];
    $wid = intval($row["WID"]);
    $revision = intval($row["Revision"]);
    return array($wid, true);
}
예제 #6
0
 function dumpit(&$var, $var_name = NULL, $indent = NULL, $reference = NULL)
 {
     $do_dump_indent = "<span style='color:#666666;'>|</span> &nbsp;&nbsp; ";
     $reference = $reference . $var_name;
     $keyvar = 'the_do_dump_recursion_protection_scheme';
     $keyname = 'referenced_object_name';
     echo "<div style='text-align:left; background-color:white; font: 100% monospace; color:black;'>";
     if (is_array($var) && isset($var[$keyvar])) {
         $real_var =& $var[$keyvar];
         $real_name =& $var[$keyname];
         $type = ucfirst(gettype($real_var));
         echo "{$indent}{$var_name} <span style='color:#666666'>{$type}</span> = <span style='color:#e87800;'>&amp;{$real_name}</span><br>";
     } else {
         $var = array($keyvar => $var, $keyname => $reference);
         $avar =& $var[$keyvar];
         $type = ucfirst(gettype($avar));
         if ($type == "String") {
             $type_color = "<span style='color:green'>";
         } elseif ($type == "Integer") {
             $type_color = "<span style='color:red'>";
         } elseif ($type == "Double") {
             $type_color = "<span style='color:#0099c5'>";
             $type = "Float";
         } elseif ($type == "Boolean") {
             $type_color = "<span style='color:#92008d'>";
         } elseif ($type == "NULL") {
             $type_color = "<span style='color:black'>";
         }
         if (is_array($avar)) {
             $count = count($avar);
             echo "{$indent}" . ($var_name ? "{$var_name} => " : "") . "<span style='color:#666666'>{$type} ({$count})</span><br>{$indent}(<br>";
             $keys = array_keys($avar);
             foreach ($keys as $name) {
                 $value =& $avar[$name];
                 dumpit($value, "['{$name}']", $indent . $do_dump_indent, $reference);
             }
             echo "{$indent})<br>";
         } elseif (is_object($avar)) {
             echo "{$indent}{$var_name} <span style='color:#666666'>{$type}</span><br>{$indent}(<br>";
             foreach ($avar as $name => $value) {
                 dumpit($value, "{$name}", $indent . $do_dump_indent, $reference);
             }
             echo "{$indent})<br>";
         } elseif (is_int($avar)) {
             echo "{$indent}{$var_name} = <span style='color:#666666'>{$type}(" . strlen($avar) . ")</span> {$type_color}" . htmlentities($avar) . "</span><br>";
         } elseif (is_string($avar)) {
             echo "{$indent}{$var_name} = <span style='color:#666666'>{$type}(" . strlen($avar) . ")</span> {$type_color}\"" . htmlentities($avar) . "\"</span><br>";
         } elseif (is_float($avar)) {
             echo "{$indent}{$var_name} = <span style='color:#666666'>{$type}(" . strlen($avar) . ")</span> {$type_color}" . htmlentities($avar) . "</span><br>";
         } elseif (is_bool($avar)) {
             echo "{$indent}{$var_name} = <span style='color:#666666'>{$type}(" . strlen($avar) . ")</span> {$type_color}" . ($avar == 1 ? "TRUE" : "FALSE") . "</span><br>";
         } elseif (is_null($avar)) {
             echo "{$indent}{$var_name} = <span style='color:#666666'>{$type}(" . strlen($avar) . ")</span> {$type_color}NULL</span><br>";
         } else {
             echo "{$indent}{$var_name} = <span style='color:#666666'>{$type}(" . strlen($avar) . ")</span> " . htmlentities($avar) . "<br>";
         }
         $var = $var[$keyvar];
     }
     echo '</div>';
 }