当前位置: 首页>>代码示例>>PHP>>正文


PHP lookup函数代码示例

本文整理汇总了PHP中lookup函数的典型用法代码示例。如果您正苦于以下问题:PHP lookup函数的具体用法?PHP lookup怎么用?PHP lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lookup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: secret

function secret($dbs, $cryptKey, $id, $data = NULL)
{
    global $db;
    $maxLen = strlen('9223372036854775807') - 1;
    // keep it shorter than biggest usable unsigned "big int" in MySQL
    $table = 'offsite';
    extract((array) $dbs[$db_name = key($dbs)], EXTR_PREFIX_ALL, 'db');
    $db = new PDO("{$db_driver}:host={$db_host};port={$db_port};dbname={$db_name}", $db_user, $db_pass);
    if (!isset($data)) {
        return offlog(35, $result = lookup('data', $table, $id)) == '' ? '' : base64_encode(ezdecrypt($result, $cryptKey));
    }
    // retrieval is easy
    $data = ezencrypt(base64_decode($data), $cryptKey);
    if ($id) {
        return offlog(38, query("UPDATE {$table} SET data=? WHERE id=?", array($data, $id)) ? $id : FALSE);
    }
    // replacing old data with new value
    while (TRUE) {
        // new data, find an unused id
        $id = randomInt($maxLen);
        if (!lookup(1, $table, $id)) {
            break;
        }
    }
    return offlog(44, query("INSERT INTO {$table} (id, data) VALUES (?, ?)", array($id, $data)) ? $id : FALSE);
}
开发者ID:maduhu,项目名称:rCredits,代码行数:26,代码来源:offsite.php

示例2: createWikiTable

function createWikiTable($header, $filelist, $filespecs, $languages)
{
    global $linkprefix;
    global $version;
    global $subversion;
    //Get the DBpedia Version Number for Preview File
    preg_match('~/([0-9]+\\.[0-9]+)/~', $linkprefix, $matches);
    echo "===" . $header . "===\n";
    echo "**NOTE: You can find DBpedia dumps in 97 languages at our ((http://downloads.dbpedia.org/" . $version . "." . $subversion . "/ DBpedia download server)).**\n\n";
    echo "//Click on the dataset names to obtain additional information.//\n";
    echo "#||\n||**Dataset**|**" . implode('**|**', $languages) . "**||\n";
    if ($header == "Core Datasets") {
        echo "||((#dbpediaontology DBpedia Ontology)) ++(<# <a href=\"http://downloads.dbpedia.org/preview.php?file=" . $version . "." . $subversion . "_sl_dbpedia_" . $version . "." . $subversion . ".owl.bz2\">preview</a> #>)++|++<# <a href=\"http://downloads.dbpedia.org/" . $version . "." . $subversion . "/dbpedia_" . $version . "." . $subversion . ".owl.bz2\" title=\"Triples: unknown; Filesize(download): unknown; Filesize(unpacked): unknown\">owl</a> #>++|++--++|++--++|++--++|++--++|++--++|++--++|++--++|++--++|++--++|++--++|++--++||";
    }
    foreach ($filelist as $name) {
        foreach ($languages as $index => $lang) {
            if ($index === 0) {
                echo '||((#' . str_replace(" ", "", strtolower($name['title'])) . ' ' . $name['title'] . ')) ++(<# <a href="http://downloads.dbpedia.org/preview.php?file=' . $matches[1] . '_sl_' . $lang . '_sl_' . $name['file'] . $lang . '.nt.bz2">preview</a> #>)++|';
            }
            echo '++' . lookup($name['file'], $lang, $filespecs) . '++|';
        }
        echo "|\n";
    }
    echo "||# \n";
}
开发者ID:ljarray,项目名称:dbpedia,代码行数:25,代码来源:downloadpagecreator.php

示例3: lookup

function lookup($user, $operation, $acl, $type)
{
    $id = (string) $user->id;
    if (isset($acl->users->{$id}) and ($acl->users->{$id}->{$type} === '*' or in_array($operation, $acl->users->{$id}->{$type}))) {
        return true;
    } elseif ($groups = intersect($acl->groups, $user->groups)) {
        foreach ($groups as $group) {
            if (isset($group->{$type}) and ($group->{$type} === '*' or in_array($operation, $group->{$type}))) {
                return true;
            }
        }
    }
    if (isset($acl->parent)) {
        return lookup($user, $operation, $acl->parent, $type);
    } else {
        return false;
    }
}
开发者ID:nyan-cat,项目名称:easyweb,代码行数:18,代码来源:acl.php

示例4: render

    render("sell_form.php", ["positions" => $positions]);
    // else if user has sold a position (stored in $_POST)
} else {
    // access variables
    $id = $_SESSION["id"];
    $id_int = intval($id);
    $symbol = $_POST["symbol"];
    $symbol_str = strval($symbol);
    $positions = $_SESSION["positions"];
    // get revenue of sold stock
    // get number of shares
    foreach ($positions as $position) {
        if ($position["symbol"] == $symbol_str) {
            $total = $position["total"];
            $shares = $position["shares"];
        }
    }
    // get price of stock
    $stock = lookup("{$symbol}");
    $price = $stock["price"];
    //add revenue of sold stock to cash
    query("UPDATE `users` SET cash = cash + {$total} WHERE id = {$id}");
    // delete position from porfolio
    query("DELETE FROM `portfolios` WHERE id = ? AND symbol = ?", $id_int, $symbol_str);
    // store transaction in transactions table
    $rows = query("SELECT NOW()");
    $datetime = $rows[0]["NOW()"];
    query("INSERT INTO `transactions` (id, transaction, datetime, symbol, shares, price)" . " VALUES (?, ?, ?, ?, ?, ?)", $id, "SELL", $datetime, $symbol, $shares, $price);
    //redirect to index.php
    redirect("index.php");
}
开发者ID:stijnblommerde,项目名称:yahoo_finance,代码行数:31,代码来源:sell.php

示例5: query

<?php

// Configuration
require "../includes/config.php";
// Get the user's id number, provided to $_SESSION upon login
$id = $_SESSION["id"];
// Declare a table to load in the data we want from lookup() and query()
$userport = [];
// Get every row from the stocks table where the id matches the session
$portquery = query("SELECT * FROM stocks WHERE id  = ?", $id);
// Query all the user's information to attain cash reserves
$userquery = query("SELECT * FROM users WHERE id  = ?", $id);
$username = $userquery[0]["username"];
// Loop through each row of the portquery
foreach ($portquery as $row) {
    // Perform a lookup on the symbol found in the current row
    $stock = lookup($row["symbol"]);
    // If there was no lookup error, i.e. $stock is not false
    if ($stock !== false) {
        // Load up the userport table with appropriate key-val pairs
        $userport[] = ["name" => $stock["name"], "symbol" => $row["symbol"], "shares" => $row["shares"], "price" => $stock["price"], "totval" => $row["shares"] * $stock["price"], "cash" => $userquery[0]["cash"]];
    }
}
?>
    
<?php 
// render portfolio
render("portfolio.php", ["title" => "Portfolio", "userport" => $userport, "username" => $username]);
开发者ID:jameskane05,项目名称:cs-finance,代码行数:28,代码来源:index.php

示例6: render

if ($_SERVER["REQUEST_METHOD"] == "GET") {
    render("buy_form.php", ["title" => "Buy"]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // ensure that a whole number > 0 was entered, no fractions of shares allowed
        $shares = $_POST["shares"];
        if (preg_match("/^\\d+\$/", $shares) == false) {
            apologize("You must enter a whole number!");
        } elseif ($shares <= 0) {
            apologize("Enter a number greater than zero!");
        }
        $symbol = strtoupper($_POST["symbol"]);
        $id = $_SESSION["id"];
        $action = "BUY";
        // get a quote for the requested share
        $quote = lookup($symbol);
        if (!$quote) {
            apologize("Symbol not found!");
        }
        // users are unique so select the first row [0]
        $user = cs50::query("SELECT * FROM users WHERE id = ?", $id)[0];
        $value = $shares * $quote["price"];
        $cash_available = $user["cash"];
        if ($value > $cash_available) {
            apologize("You don't have enough cash!");
        }
        // add purchase to user's portfolio
        cs50::query("INSERT INTO portfolios (user_id, symbol, shares) VALUES (?, ?, ?)\n            ON DUPLICATE KEY UPDATE shares = shares + ?", $id, $symbol, $shares, $shares);
        // set user's cash to reflect purchase
        cs50::query("UPDATE users SET cash = cash - ? WHERE id = ?", $value, $id);
        // add purchase information into history
开发者ID:Somniloquist,项目名称:cs50,代码行数:31,代码来源:buy.php

示例7: str_replace

    $string = str_replace(" ", "+", urlencode($string));
    $details_url = "http://maps.googleapis.com/maps/api/geocode/json?address=" . $string . "&sensor=false";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $details_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = json_decode(curl_exec($ch), true);
    // If Status Code is ZERO_RESULTS, OVER_QUERY_LIMIT, REQUEST_DENIED or INVALID_REQUEST
    if ($response['status'] != 'OK') {
        return null;
    }
    $geometry = $response['results'][0]['geometry'];
    $array = array('latitude' => $geometry['location']['lat'], 'longitude' => $geometry['location']['lng']);
    return $array;
}
$result = mysqli_query($conn, "Select id,Address,City,Zip,State,Latitude,Longitude from tbl_name;");
if (!$result) {
    die('Invalid query: ' . mysql_error());
} else {
    if (mysqli_num_rows($result) == 0) {
        die("No rows found.");
    }
    while ($row = mysqli_fetch_assoc($result)) {
        if ($row["Latitude"] != 0 || $row["Longitude"] != 0) {
            continue;
        }
        $latlon = lookup($row['Address'] . " " . $row['City'] . " " . $row['Zip'] . " " . $row['State']);
        mysqli_query($conn, "Update tbl_name set Latitude ='" . $latlon["latitude"] . "', Longitude = '" . $latlon["longitude"] . "' where id=" . $row["id"] . ";");
        echo $row['Address'] . " " . $latlon["latitude"] . "  " . $latlon["longitude"] . " <br />";
    }
}
include "CloseConnection.php";
开发者ID:Phoxloxley,项目名称:openChildCare1,代码行数:31,代码来源:geocodeScript.php

示例8: htmlentities

                <input type="text" class="form-control" name="search" placeholder="ex: University of Central Florida">
            </div>
			
			<button type="submit" class="btn btn-primary">Search</button>
        </form>

<?php 
// TESTING NOTE: To see function results, change "$see_output" value to True
$see_output = False;
if (isset($_POST['search']) && trim($_POST['search']) != '') {
    $search = $_POST['search'];
    $Name = '%' . $search . '%';
    $search_string = htmlentities($search);
    //We use google's geocode api to take in the place of interest
    //and see if we can return a valid result back from it.
    $search_lookup = lookup($search_string);
    if ($see_output) {
        print_r($search_lookup);
    }
    $search_name = "SELECT * \n                FROM University U\n                WHERE U.Name like :name  AND U.University_id <> 1";
    $university_name_params = array(':name' => $Name);
    $result_name = $db->prepare($search_name);
    $result_name->execute($university_name_params);
    $number = $result_name->rowCount();
    if ($number == 1) {
        echo "<h3><strong>{$number} result found searching for '{$search_string}' by Name. </strong></h3><hr/>";
    } else {
        echo "<h3><strong>{$number} results found searching for '{$search_string}' by Name. </strong></h3><hr/>";
    }
    while ($row = $result_name->fetch()) {
        $Name = $row['Name'];
开发者ID:jessmay,项目名称:databases-project,代码行数:31,代码来源:index.php

示例9: apologize

        apologize("Error communicating with databse");
    } else {
        render("sell_form.php", ["title" => "Sell Form", "symbols" => $symbols]);
    }
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // if no stock was selected to back to index
        if ($_POST["symbol"] === " ") {
            redirect("/");
        }
        // put symbol into a variable
        $symbol = $_POST["symbol"];
        // look up the number of shares of that stock a user has
        $shares = query("SELECT shares FROM portfolios WHERE id = ? AND symbol = '{$symbol}'", $_SESSION["id"]);
        // get current information on stock
        $stock = lookup($symbol);
        // the amount of money selling all shares of that stock would be worth
        $sale_value = $stock["price"] * $shares[0]["shares"];
        // delete that stock form their portfolio
        if (query("DELETE FROM portfolios WHERE id = ? AND symbol = '{$symbol}'", $_SESSION["id"]) === false) {
            apologize("error communicating with databse");
        }
        // update the amount of cash a user now has
        if (query("UPDATE users SET cash = cash + {$sale_value} WHERE id = ?", $_SESSION["id"]) === false) {
            apologize("error communicating with databse");
        }
        // put sale into history
        if (query("INSERT INTO history (id, symbol, shares, price, boughtSold)\n            VALUES(?, '{$symbol}', ?, ?, 'SELL')", $_SESSION["id"], $shares[0]["shares"], $stock["price"]) === false) {
            apologize("error communicating with databse");
        }
        // redirect to index
开发者ID:daniel-wakefield,项目名称:cs50-final-project,代码行数:31,代码来源:sell.php

示例10: query

                if ($qty == $boh[0]["shares"]) {
                    query("DELETE from shares WHERE id = ? AND ticker = UPPER(?)", $id, $ticker);
                }
                if (query("COMMIT") === false) {
                    if (query("ROLLBACK")) {
                        apologize("TRANSACTION ERROR, ROLLED BACK");
                    } else {
                        apologize("CRITICAL: TRANSACTION ERROR *AND* ROLLBACK FAILED!!!");
                    }
                } else {
                    redirect("index.php");
                }
            }
        }
    }
} else {
    $data = array();
    $stocksheld = query("SELECT * FROM shares WHERE id = ?", $id);
    foreach ($stocksheld as $stock) {
        $stockticker = $stock["ticker"];
        $shares = $stock["shares"];
        $lookup = lookup($stockticker);
        $price = $lookup["price"];
        $name = $lookup["name"];
        $data[$stockticker] = ["ticker" => $stockticker, "shares" => $shares, "price" => $price, "name" => $name];
    }
    if ($stocksheld === false) {
        apologize("No Stock to Sell");
    }
    render("sell_form.php", ["title" => "Sell Shares", "data" => $data]);
}
开发者ID:jdizzle1207,项目名称:cs50,代码行数:31,代码来源:sell.php

示例11: render

<?php

// configuration
require "../includes/config.php";
// if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // render the quote (validation in the template... sorry but your MVC videos werent working and I dont see the point
    render("price_quote.php", ["stock" => lookup($_POST["symbol"])]);
} else {
    // else render only form
    render("price_quote_request.php", ["title" => "Request Price Quote"]);
}
开发者ID:spitis,项目名称:cs50,代码行数:12,代码来源:quote.php

示例12: getenv

    $ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
    $ip = getenv('HTTP_X_FORWARDED_FOR');
} else {
    $ip = getenv('REMOTE_ADDR');
}
if (file_exists('/etc/redhat-release')) {
    $fnewsize = filesize('/etc/redhat-release');
    $fp = fopen('/etc/redhat-release', 'r');
    $redhat = fread($fp, $fnewsize);
    fclose($fp);
}
$Fields = $dbc->db->dsn;
$Fields['SYSTEM'] = $redhat;
$Fields['MYSQL'] = $row['VERSION'];
$Fields['PHP'] = phpversion();
$Fields['FLUID'] = RBAC_VERSION;
$Fields['IP'] = lookup($ip);
$Fields['ENVIRONMENT'] = SYS_SYS;
$Fields['SERVER_SOFTWARE'] = getenv('SERVER_SOFTWARE');
$Fields['SERVER_NAME'] = getenv('SERVER_NAME');
$Fields['SERVER_PROTOCOL'] = getenv('SERVER_PROTOCOL');
$Fields['SERVER_PORT'] = getenv('SERVER_PORT');
$Fields['REMOTE_HOST'] = getenv('REMOTE_HOST');
$Fields['SERVER_ADDR'] = getenv('SERVER_ADDR');
$Fields['HTTP_USER_AGENT'] = getenv('HTTP_USER_AGENT');
$Fields['a'] = $dbc;
$G_PUBLISH = new Publisher();
$G_PUBLISH->SetTo($dbc);
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'rbac/dbInfo', '', $Fields, 'appNew2');
G::RenderPage('publish');
开发者ID:emildev35,项目名称:processmaker,代码行数:31,代码来源:dbInfo.php

示例13: printf

<?php

if (isset($portfolio)) {
    if (empty($portfolio)) {
        printf("Your portfolio is empty! Go <a href = \"quote.php\">buy stocks</a> and build your portfolio now!");
    } else {
        ?>
<form method="post" action="sell-confirm.php"> <!--action="sell-confirm.php" -->
    <fieldset> 
        <div class="form-group"> 
            <select class = "form-control" name = "sellStock">
                <?php 
        if (isset($portfolio)) {
            foreach ($portfolio as $item) {
                printf("<option style=\"width:200px;text-align:center\" value = " . $item["symbol"] . ">");
                $ticker = lookup($item["symbol"]);
                printf($ticker["name"] . " (" . $ticker["symbol"] . ")");
                printf("</option>");
            }
        }
        ?>
            </select>
        </div>
        <div class="form-group">
            <input class="form-control" style = "text-align:center" align = "center" autocomplete = "off" name="sellShares" placeholder="Shares" />
        </div>
        <div class = "form-group">
            <p id = "calculation"></p>
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-default">Sell Shares</button>
开发者ID:jayrav13,项目名称:cs50,代码行数:31,代码来源:sell_form.php

示例14: calculateCost

function calculateCost($ticker, $shares)
{
    $data = lookup($ticker);
    return $data["price"] * $shares;
}
开发者ID:jayrav13,项目名称:cs50,代码行数:5,代码来源:functions.php

示例15: history

/**
 * Puts data into history table.
 */
function history($transaction, $symbol, $shares)
{
    $price = lookup($symbol);
    // $price["price"] *= $shares;
    query("INSERT INTO history (id, transaction, symbol, shares, price) VALUES(?, ?, ?, ?, ?)", $_SESSION["id"], $transaction, $symbol, $shares, $price["price"]);
}
开发者ID:helinp,项目名称:Sghr_hr_br49,代码行数:9,代码来源:functions.php


注:本文中的lookup函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。