예제 #1
0
function diff()
{
    global $argc, $argv;
    if ($argc != 3) {
        usage();
    }
    $file = $argv[2];
    if (file_exists($file)) {
        $xml = @simplexml_load_file($file);
    } else {
        file_not_found($file);
    }
    if ($xml === false) {
        bad_xml($file);
    }
    echo "Analysing {$file}...\n";
    // Go through nodes and mark ways that have changed (we can easiky keep it in memory)
    // rq: use floats or strings but not ints, since PHP_INT_MAX is too small on 32 bits systems
    $impacted_ways = array();
    $nodes = $xml->node;
    foreach ($nodes as $node) {
        $nodeid = (string) $node->attributes()->id;
        $nodeaction = (string) $node->attributes()->action;
        if ((double) $nodeid < 0 || $nodeaction === 'modify') {
            $results = $xml->xpath("//way[count(nd[@ref='{$nodeid}'])>0]");
            if (count($results)) {
                foreach ($results as $way) {
                    $wayid = (string) $way->attributes()->id;
                    if (!isset($impacted_ways[$wayid])) {
                        $impacted_ways[$wayid] = 1;
                    }
                }
            }
        }
    }
    // we go through ways, but only the ones that have a c2c:id attached
    // (other are part of a relation)
    $impacted_relations = array();
    $ways = $xml->way;
    foreach ($ways as $way) {
        // If only the nodes of a way have been modified or deleted, the way itself is not marked
        // as changed in josm. Let's check that.
        $wayid = (string) $way->attributes()->id;
        $propaged_modification = array_key_exists($wayid, $impacted_ways);
        $state = state($way);
        if ($propaged_modification && $state === 'NOCHANGE') {
            $state = 'MODIFY';
        }
        // check if it has a c2c:id attached
        // other ways are handled via their parent relation
        $c2cid = c2cid($way);
        if ($c2cid) {
            for ($i = 0; $i < count($c2cid); $i++) {
                $changes[$c2cid[$i]][$state][] = $wayid;
                if (!isset($changes[$c2cid[$i]]['name'])) {
                    $changes[$c2cid[$i]]['name'] = c2cname($way, $i);
                }
            }
        } else {
            // determine if way has changed (either directly or via its nodes)
            // if so, keep track of the related relations that will be considered modified
            if ($state === 'MODIFY') {
                $results = $xml->xpath("//relation[count(member[@ref='{$wayid}'])>0]");
                if (count($results)) {
                    foreach ($results as $relation) {
                        $relationid = (string) $relation->attributes()->id;
                        if (!isset($impacted_relations[$relationid])) {
                            $impacted_relations[$relationid] = 1;
                        }
                    }
                }
            }
        }
    }
    // we go through the relations
    $relations = $xml->relation;
    foreach ($relations as $relation) {
        $relationid = (string) $relation->attributes()->id;
        $propaged_modification = array_key_exists($relationid, $impacted_relations);
        $state = state($relation);
        if ($propaged_modification && $state === 'NOCHANGE') {
            $state = 'MODIFY';
        }
        $c2cid = c2cid($relation);
        if ($c2cid) {
            for ($i = 0; $i < count($c2cid); $i++) {
                $changes[$c2cid[$i]][$state][] = $relationid;
                if (!isset($changes[$c2cid[$i]]['name'])) {
                    $changes[$c2cid[$i]]['name'] = c2cname($relation, $i);
                }
            }
        } else {
            die("Found a relation without c2c:id. Aborting...\n");
        }
    }
    // display the changes in a human readable way
    echo "\n";
    foreach ($changes as $id => $change) {
        $modifycount = isset($change['MODIFY']) ? count($change['MODIFY']) : 0;
        $deletecount = isset($change['DELETE']) ? count($change['DELETE']) : 0;
        $newcount = isset($change['NEW']) ? count($change['NEW']) : 0;
        $nochangecount = isset($change['NOCHANGE']) ? count($change['NOCHANGE']) : 0;
        // an area has been completely deleted
        if ($deletecount > 0 && $modifycount == 0 && $newcount == 0 && $nochangecount == 0) {
            echo $change['name'] . " ({$id}) has been deleted\n";
            continue;
        }
        // a new area has been created
        if ($newcount > 0 && $modifycount == 0 && $deletecount == 0 && $nochangecount == 0) {
            echo $change['name'] . " ({$id}) has been created with {$newcount} polygon(s)\n";
            continue;
        }
        // modified in various ways
        if ($newcount > 0 || $modifycount > 0 || $deletecount > 0) {
            echo $change['name'] . " ({$id}) has been changed\n";
            continue;
        }
    }
}
예제 #2
0
 public static function help($params = array())
 {
     $cli = new BedrockYAML(self::$script_dir . "/code/lib/_cli.yml");
     $allowed_actions = $cli->getAllowedActions();
     say(cell("Command", 20, true, "grey", "on_white") . cell("Description", 50, true, "grey", "on_white") . cell("Options", 50, true, "grey", "on_white"));
     foreach ($allowed_actions as $a) {
         $options = array();
         foreach ($a->getOptions() as $o) {
             $options[] = "[" . $o->get('arg') . "] ";
             foreach ($o->get('description') as $line) {
                 $options[] = $line;
             }
             $options[] = "";
         }
         array_pop($options);
         $descriptions = $a->getDescription()->toArray();
         $source = sizeof($options) > sizeof($descriptions) ? $options : $descriptions;
         for ($i = 0; $i < sizeof($source); $i++) {
             $cmd = $i == 0 ? $a->getKey() : "";
             state(cell($cmd, 20, false));
             $desc = isset($descriptions[$i]) ? $descriptions[$i] : "";
             $opt = isset($options[$i]) ? $options[$i] : "";
             state(cell($desc, 50, false));
             state(cell($opt, 50, false));
             state("\n");
         }
         say(cell("", 20) . cell("", 50) . cell("", 50));
     }
 }
function asthma_process_test_with_controller(FSM &$fsm, &$data)
{
    $data->val = 'init';
    state($fsm, $data);
    $fsm->process(INPUT_HEALTHY_ASTHMA);
    state($fsm, $data);
    $fsm->process(INPUT_YES);
    state($fsm, $data);
    $fsm->process(INPUT_UNKNOWN);
    state($fsm, $data);
    $fsm->process(INPUT_TWO_VALID_TIMES_OF_DAY);
    state($fsm, $data);
    // if current state is proflie complete then $fsm->process(WELCOME); (could just process)
    $fsm->process(WELCOME);
    state($fsm, $data);
    $fsm->process(INPUT);
    state($fsm, $data);
    $fsm->process(ACTIVE_MESSAGE);
    state($fsm, $data);
    $fsm->process(ACTIVE_MESSAGE);
    state($fsm, $data);
    $fsm->process(INPUT);
    state($fsm, $data);
    // if we are out of message then     $fsm->process(RAN_OUT_OF_MESSAGES);
    $fsm->process(RAN_OUT_OF_MESSAGES);
    state($fsm, $data);
    $fsm->process(INPUT);
    state($fsm, $data);
    $fsm->process(INPUT);
    state($fsm, $data);
    $fsm->process(INPUT);
    state($fsm, $data);
    $fsm->process(INPUT);
    state($fsm, $data);
    ///
    //    $fsm->reset();
    //    $fsm->process('INPUT_HEALTHY_ASTHMA');
    //    $fsm->process('INPUT_NO');
    //    $fsm->process('INPUT_UNKNOWN');
    //    $fsm->process('INPUT_ONE_VALID_TIME');
    //    $fsm->process('WELCOME');
    state($fsm, $data);
}
예제 #4
0
파일: delivery.php 프로젝트: eginwong/Loof
<?php

$connection = mysqli_connect("localhost", "e47wong", "Fall2014", "e47wong") or die("Error " . mysqli_error($link));
//This switch determines which function will be performed based on what parameters are passed in.
if (isset($_POST['json_data']) && !empty($_POST['json_data'])) {
    ajaxDeliver(json_decode($_POST['json_data']));
} else {
    if (isset($_GET['action']) && !empty($_GET['action'])) {
        state($_GET['p'], $_GET['s'], $_GET['o'], $_GET['action'], $_GET['r']);
    } else {
        $return = array();
        $return = searchRestaurants();
        echo json_encode($return);
    }
}
/*Function changes the state of the order and reflects that change to the database.
Input  - $state, $orderID, $call, [$profile, $rating], only required variables are the state, call, and the orderID.*/
function state($profile, $state, $orderID, $call, $rating)
{
    global $connection;
    //This case simulates if the user chooses to accept the order to deliver.
    if ($call == "inc") {
        ++$state;
        $query1 = "SELECT userID FROM `User` WHERE fBLink LIKE '{$profile}'" or die("Error in the consult.." . mysqli_error($connection));
        $res = $connection->query($query1);
        $obj = $res->fetch_row();
        $userID = $obj[0];
        //Update the database and place the user as the deliveryID.
        $query = "UPDATE `Order` SET `deliveryID` = {$userID}, `state` = {$state} WHERE `orderID` = {$orderID}" or die("Error in the consult.." . mysqli_error($connection));
        $result = $connection->query($query);
    } else {
예제 #5
0
         say("You can run 'silversmith fix-mamp' resolve this issue.");
         $answer = ask("Press any key to show the error output...");
         say("Connection error: {$conn->connect_error}");
     }
 }
 DB::connect($databaseConfig);
 say("done");
 $project_dir = isset($PARAMS['module']) ? $PARAMS['module'] : project();
 SilverSmith::set_project_dir($project_dir);
 if ($action != "init") {
     $yml_file = isset($PARAMS['file']) ? $PARAMS['file'] : "_project.yml";
     $yml_path = SilverSmith::get_project_dir() . "/{$yml_file}";
     if (!file_exists($yml_path)) {
         fail("File {$yml_path} does not exist. Use 'silversmith init' to create it.");
     }
     state("Bootstrapping SilverSmith...");
     SilverSmith::set_yaml_path($yml_path);
     SilverSmithProject::load($yml_path);
     SilverSmith::load_field_manifest();
     SilverSmith::load_class_manifest();
     SilverSmith::load_interface_manifest();
     // Check for an upgrade every hour
     $time = time();
     $stamp = @file_get_contents($script_dir . "/upgrade");
     if (!$stamp) {
         $stamp = $time;
     }
     $diff = $time - (int) $stamp;
     if ($diff > 3600) {
         say("Checking for upgrade...");
         SilverSmith::upgrade();
예제 #6
0
<?php

session_start();
require '../model/client.php';
require_once "../lib/connect.php";
$client = new client();
$email = post_value_or('email');
$password = post_value_or("mdp");
$myreturn = $client->auth($email, $password);
if (mysqli_num_rows($myreturn) > 0) {
    $_SESSION['login'] = get_info($email);
    $state = state($email);
    if ($state == "client") {
        header("location:/banc/view/welcome.php");
    } else {
        header("location:/banc/view/admin.php");
    }
} else {
    header("location:/banc/view/login.php");
}
function post_value_or($key, $default = NULL)
{
    return isset($_POST[$key]) && !empty($_POST[$key]) ? $_POST[$key] : $default;
}
function get_info($ch)
{
    $con = new connect();
    $rs = $con->Query(" select * from admin where email='{$ch}' ");
    $data = $rs->fetch_array();
    return $data["id"];
}
예제 #7
0
          title : "Property Details",
          url : "<?php 
the_permalink();
?>
",
          idleMapZoom : GSmapSearchControl.ACTIVE_MAP_ZOOM,
          activeMapZoom : GSmapSearchControl.ACTIVE_MAP_ZOOM
          }		
    new GSmapSearchControl(
          document.getElementById("mapsearch"),
          "<?php 
the_title();
?>
, <?php 
city();
?>
, <?php 
state();
?>
, <?php 
zipcode();
?>
",
          options
          );
    }
    GSearch.setOnLoadCallback(LoadMapSearchControl);
</script>
<div id="location" class="right">
    <div id="mapsearch">Loading...</div>
</div>
function sendstate($id, $fromdate, $todate, $type, $email, $body = "Statement attached in pdf format.")
{
    db_conn('cubit');
    $es = qryEmailSettings();
    require_lib("validate");
    $v = new validate();
    $v->isOk($id, "num", 1, 20, "Invalid id.");
    if ($v->isError()) {
        $err = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $err .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    $Sl = "SELECT * FROM customers WHERE cusnum='{$id}'";
    $Ri = db_exec($Sl);
    $cd = pg_fetch_array($Ri);
    if (strlen($email) < 1) {
        return "This customer does not have an email address";
    }
    //	$body = "Statement attached in pdf format.";
    $send_cc = "";
    $send_bcc = "";
    $smtp_data['signature'] = $es['sig'];
    $smtp_data['smtp_from'] = $es['fromname'];
    $smtp_data['smtp_reply'] = $es['reply'];
    $smtp_data['smtp_host'] = $es['smtp_host'];
    $smtp_data['smtp_auth'] = $es['smtp_auth'];
    $smtp_data['smtp_user'] = $es['smtp_user'];
    $smtp_data['smtp_pass'] = $es['smtp_pass'];
    // build msg body
    $body = "{$body}\n\n{$smtp_data['signature']}";
    // determine whether or not here is an attachment
    //$has_attachment = is_uploaded_file($attachment["tmp_name"]);
    $has_attachment = true;
    // modify message and create content_type header depending on whether or not an attachment was posted
    if ($has_attachment == false) {
        $content_type = "text/html;charset=US-ASCII";
        $transfer_encoding = "8bit";
    } else {
        // has attachment
        $content_type = "multipart/mixed";
        // create the main body
        $body_text = "Content-Type: text/plain; charset=US-ASCII\n";
        $body_text .= "Content-Transfer-Encoding: base64\n";
        $body_text .= "\n" . chunk_split(base64_encode($body));
        // get the attachment data
        $attachment = array();
        $attachment["data"] = state($id, $fromdate, $todate, $type);
        $attachment["name"] = "statement.pdf";
        // delete the temporary file
        $attachment["data"] = chunk_split(base64_encode($attachment["data"]));
        $attachment["headers"] = "Content-Type: application/x-pdf; name=\"{$attachment['name']}\"\n";
        $attachment["headers"] .= "Content-Transfer-Encoding: base64\n";
        $attachment["headers"] .= "Content-Disposition: attachment; filename=\"{$attachment['name']}\"\n";
        $attachment["data"] = "{$attachment['headers']}\n{$attachment['data']}";
        // generate a unique boundary ( md5 of filename + ":=" + filesize )
        $boundary = md5($attachment["name"]) . "=:" . strlen($attachment["data"]);
        $content_type .= "; boundary=\"{$boundary}\"";
        // put together the body
        $body = "\n--{$boundary}\n{$body_text}\n\n--{$boundary}\n{$attachment['data']}\n\n--{$boundary}--\n";
    }
    // build headers
    $headers[] = "From: {$smtp_data['smtp_from']}";
    $headers[] = "To: {$email}";
    $headers[] = "Reply-To: {$smtp_data['smtp_reply']}";
    $headers[] = "X-Mailer: Cubit Mail";
    $headers[] = "Return-Path: {$smtp_data['smtp_reply']}";
    $headers[] = "Content-Type: {$content_type}";
    $headers[] = "cc: {$send_cc}";
    $headers[] = "bcc: {$send_bcc}";
    // create the mime header if should
    if ($has_attachment == TRUE) {
        $headers[] = "MIME-Version: 1.0";
    }
    // create the header variable (it is done this way, to make management of headers easier, since there
    // may be no tabs and unnecesary whitespace in mail headers)
    //$headers[] = "\n"; // add another new line to finish the headers
    $headers = implode("\n", $headers);
    //return "done";
    // send the message
    $sendmail =& new clsSMTPMail();
    $OUTPUT = $sendmail->sendMessages($smtp_data["smtp_host"], 25, $smtp_data["smtp_auth"], $smtp_data["smtp_user"], $smtp_data["smtp_pass"], $email, $smtp_data["smtp_from"], "Statement", $body, $headers);
    /*if ( mail($send_to, $subject, $body, $headers) == TRUE )
    		$OUTPUT = "Successfully sent mail to $send_to.<br>";
    	else
    		$OUTPUT = "Error sending mail.<br>";*/
    return $OUTPUT;
}