Пример #1
0
function main()
{
    global $ACCESS_TOKEN, $USER_AGENT;
    // Set the API sport, method, id, format, and any parameters
    $host = 'erikberg.com';
    $sport = '';
    $method = 'events';
    $id = '';
    $format = 'json';
    $parameters = array('sport' => 'nba', 'date' => '20130414');
    // Pass method, format, and parameters to build request url
    $url = buildURL($host, $sport, $method, $id, $format, $parameters);
    // Set the User Agent, Authorization header and allow gzip
    $default_opts = array('http' => array('user_agent' => $USER_AGENT, 'header' => array('Accept-Encoding: gzip', 'Authorization: Bearer ' . $ACCESS_TOKEN)));
    stream_context_get_default($default_opts);
    $file = 'compress.zlib://' . $url;
    $fh = fopen($file, 'rb');
    if ($fh && strpos($http_response_header[0], "200 OK") !== false) {
        $content = stream_get_contents($fh);
        fclose($fh);
        printResult($content);
    } else {
        // handle error, check $http_response_header for HTTP status code, etc.
        if ($fh) {
            $xmlstats_error = json_decode(stream_get_contents($fh));
            printf("Server returned %s error along with this message:\n%s\n", $xmlstats_error->error->code, $xmlstats_error->error->description);
        } else {
            print "A problem was encountered trying to connect to the server!\n";
            print_r(error_get_last());
        }
    }
}
function printTop10TeamsGamesPlayed($orderBy, $showTop)
{
    $conn = connectToDatabase();
    $query = "SELECT Name, Leader, Game_Count, Win_Count, 100*Win_Count/Team.Game_Count FROM TEAM ORDER BY Game_Count " . $orderBy . " LIMIT " . $showTop;
    $result = $conn->query($query);
    printResult($result);
    $conn->close();
}
Пример #3
0
function printCookbook($cookbook_id)
{
    $conn = getConn();
    $sql = " SELECT cb_title FROM cookbook\n\t\t\t\tWHERE cookbook_id = '{$cookbook_id}'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    echo '<h1>' . $row["cb_title"] . '</h1>';
    $sql = " SELECT  * FROM recipe\n\t\t\t\tWHERE recipe_id in (\n\t\t\t\t\tSELECT recipe_id FROM recipe_list\n\t\t\t\t\tWHERE cookbook_id = '{$cookbook_id}')";
    $result = $conn->query($sql);
    printResult($result);
}
Пример #4
0
function test()
{
    if (isset($_GET) && isset($_GET["keywords"]) && isset($_GET["target"])) {
        $db = connect();
        $json = search($_GET["keywords"], $_GET["target"], $db);
        $arr = json_decode($json, true);
        if (isset($arr["movie"])) {
            $m = $arr["movie"];
            echo "<h3>Movies</h3>";
            $me = $m["exact"];
            echo "<b>Exact Results:</b><br />";
            printResult($me);
            $mc = $m["close"];
            echo "<b>Close Results:</b><br />";
            printResult($mc);
            $mp = $m["partial"];
            echo "<b>Partial Results:</b><br />";
            printResult($mp);
        }
        if (isset($arr["actor"])) {
            $a = $arr["actor"];
            echo "<h3>Actors</h3>";
            $ae = $a["exact"];
            echo "<b>Exact Results:</b><br />";
            printResult($ae);
            $ap = $a["partial"];
            echo "<b>Partial Results:</b><br />";
            printResult($ap);
        }
        if (isset($arr["director"])) {
            $d = $arr["director"];
            echo "<h3>Directors</h3>";
            $de = $d["exact"];
            echo "<b>Exact Results:</b><br />";
            printResult($de);
            $dp = $d["partial"];
            echo "<b>Partial Results:</b><br />";
            printResult($dp);
        }
        disconnect($db);
    }
}
function cbTagBrowse()
{
    $conn = getConn();
    $tags = $_POST["tags"];
    $len = count($tags);
    if ($len <= 1) {
        $tag = $tags[0];
        $sql = " SELECT * FROM cookbook\n\t\t\t\t\tWHERE cookbook_id in (\n\t\t\t\t\t\tSELECT type_id FROM tag\n\t\t\t\t\t\tWHERE name = '{$tag}' AND type = 'COOKBOOK')";
    } else {
        $first = $tags[0];
        $sql = " SELECT type_id FROM tag\n\t\t\t\t\tWHERE name = '{$first}' AND type = 'COOKBOOK' ";
        for ($i = 1; $i < $len; $i++) {
            $current = $tags[$i];
            $sql = " SELECT type_id FROM tag\n\t\t\t\t\t\tWHERE name = '{$current}' \n\t\t\t\t\t\t\tAND type = 'COOKBOOK'\n\t\t\t\t\t\t\tAND type_id in (" . $sql . ")";
        }
        $sql = " SELECT * FROM cookbook\n\t\t\t\t\tWHERE cookbook_id in (" . $sql . ")";
    }
    printResult($conn->query($sql));
    $conn->close();
}
Пример #6
0
if (isset($_POST['checkTime']) && $_POST['checkTime'] > time() - 60 * 5) {
    // Initiate the MetaTune object.
    $spotiy = MetaTune::getInstance();
    $out = '<div class="masterResult">';
    if (!empty($_POST['artist'])) {
        // Get a list of artists
        $response = $spotiy->searchArtist($_POST['artist']);
        $out .= "<div class=\"resultBox\"><h2>Artists</h2>";
        $out .= printResult($response);
        $out .= "</div>";
    }
    if (!empty($_POST['album'])) {
        // Get a list of albums from search
        $response = $spotiy->searchAlbum($_POST['album']);
        $out .= "<div class=\"resultBox\"><h2>Albums</h2>";
        $out .= printResult($response);
        $out .= "</div>";
    }
    if (!empty($_POST['track'])) {
        // Search and get a list of tracks/song.
        $response = $spotiy->searchTrack($_POST['track']);
        $out .= "\t<div class=\"last\">\n\t<h2>Tracks</h2>\n";
        $out .= songResult($response);
        $out .= "\t</div>\n";
    }
    $out .= "</div>\n";
    echo $out;
}
if (DEBUG) {
    $end = microtime();
    echo "<pre>Debug time: " . ($end - $start) . "</pre>";
Пример #7
0
<?php

connectDB("{$gasDatabaseName}");
if ($action == 'GetPosition') {
    // 寻找还没有被接单的订单, 且已经支付的订单
    $sql = "select * from GasOrder,Customer where GasOrder.Uid = Customer.Uid and OrderDelivery = 0 and OrderStatus = 1 and OrderComplete = 0";
    printResult($sql);
} else {
    if ($action == "ReceiveOrder") {
        // gasman接订单
        $orderId = post("OrderId");
        $orderDistance = post("OrderDistance");
        $uid = session("Uid");
        $sql = "update GasOrder set OrderDelivery = 1, GasmanId = {$uid}, OrderDistance = '{$orderDistance}' where OrderId = {$orderId}";
        query("{$sql}");
        printResultByMessage("", 0);
    }
}
Пример #8
0
<?php

$digits = findDigits(1234);
printResult($digits);
$digits = findDigits(145);
printResult($digits);
$digits = findDigits(15);
printResult($digits);
$digits = findDigits(247);
printResult($digits);
function printResult($digits)
{
    if (count($digits) > 0) {
        echo implode(', ', $digits);
    } else {
        echo "no";
    }
    echo "<hr>";
}
function findDigits($n)
{
    $array = [];
    if ($n < 100) {
        return $array;
    }
    for ($i = 1; $i <= 9; $i++) {
        for ($j = 0; $j <= 9; $j++) {
            for ($k = 0; $k <= 9; $k++) {
                if ($i != $j && $j != $k && $k != $i) {
                    $result = "{$i}{$j}{$k}";
                    if ((int) $result <= $n) {
Пример #9
0
$mysql = new mysqli("localhost", "root", "vodoley14", "users");
// if (!$mysql) {
// 	echo "dont work";
// } else {
// 	echo "work";
// }
$mysql->query("SET NAMES 'utf8");
$result_set = $mysql->query("SELECT * FROM `users_table`");
if (isset($_POST['add'])) {
    // print_r($_POST);
    $name = $_POST['name'];
    $html = htmlspecialchars($_POST['html']);
    $mysql->query("INSERT INTO `users_table` (`name`,`date`,`html`,`update`) VALUES ('" . $name . "','" . time() . "','" . $html . "','" . time() . "')");
    header('Location: index.php');
}
printResult($result_set);
$mysql->close();
date_default_timezone_set("Europa/Lviv");
echo "The time is " . date("h:i:sa");
?>
 <!DOCTYPE html>
 <html lang="en">
 <head>
 	<style>
 	table {
    border-collapse: collapse;
}
		td {
			border: 1px solid black;
		}
		#delete {
Пример #10
0
function getLeads($reindeers)
{
    $max = 0;
    $leads = [];
    foreach ($reindeers as $name => $r) {
        if ($r['distance'] > $max) {
            $max = $r['distance'];
            $leads = [$name];
        } elseif ($r['distance'] == $max) {
            $leads[] = $name;
        }
    }
    return $leads;
}
function printResult($reindeers)
{
    $maxDist = 0;
    $maxPoints = 0;
    foreach ($reindeers as $name => $r) {
        printf("%s\t%d m\t%d points\n", $name, $r['distance'], $r['points']);
        $maxDist = $r['distance'] > $maxDist ? $r['distance'] : $maxDist;
        $maxPoints = $r['points'] > $maxPoints ? $r['points'] : $maxPoints;
    }
    print "Max distance:\t{$maxDist}\n";
    print "Max points:\t{$maxPoints}\n";
}
for ($i = 0; $i < $seconds; $i++) {
    increment($reindeers);
}
printResult($reindeers);
Пример #11
0
function printTable($table)
{
    $result = executePlainSQL("select * from {$table}");
    echo "<br>Got data from table {$table}:<br>";
    printResult($result);
}
Пример #12
0
            $timeTaken[$regnum][$itter][$strnum] = (microtime(true) - $iterStarTime) * 1000;
            // count how many times we test against the large string on this regex
            if ($strnum == 5) {
                $testedAgainstLargeString++;
            }
            if (debug && $itter % 1000 == 0) {
                echo $b;
            }
            if (debug && $itter % 1000 == 0) {
                echo " took " . $timeTaken[$regnum][$itter][$strnum] . "ms" . "\n";
            }
        }
    }
}
$endTime = microtime(true);
printResult("QUERUCS", $timeTaken, ($endTime - $startTime) * 1000, $matches);
function printResult($regexName, &$matrix, $totalTime, $matches)
{
    global $re, $str;
    // timeTaken[regnum,itter,strnum]
    if (html) {
        echo "<table>";
        echo "<tr><th colspan=\"3\"><h2>Regular expression library:</h2></th><td colspan=\"3\"><h2>" . $regexName . "</h2></td></tr>";
    } else {
        echo "------------------------------------------";
        echo "Regular expression library: " . $regexName . "\n";
    }
    for ($ire = 0; $ire < count($re); $ire++) {
        if (html) {
            echo "<tr><th>RE:</th><td colspan=\"5\">" . $re[$ire] . "</td></tr>";
            echo "<tr><th>MS</th><th>MAX</th><th>AVG</th><th>MIN</th><th>DEV</th><th>INPUT</th><th>MATCH</th></tr>";
Пример #13
0
$log->LogInfo("===========处理后台请求开始============");
$params = array('version' => '5.0.0', 'encoding' => 'utf-8', 'certId' => getSignCertId(), 'signMethod' => '01', 'txnType' => '03', 'txnSubType' => '00', 'bizType' => '000201', 'accessType' => '0', 'channelType' => '07', 'backUrl' => SDK_BACK_NOTIFY_URL, 'orderId' => $_POST["orderId"], 'merId' => $_POST["merId"], 'origQryId' => $_POST["origQryId"], 'txnTime' => $_POST["txnTime"], 'txnAmt' => $_POST["txnAmt"]);
sign($params);
// 签名
$url = SDK_BACK_TRANS_URL;
$log->LogInfo("后台请求地址为>" . $url);
$result = post($params, $url, $errMsg);
if (!$result) {
    //没收到200应答的情况
    printResult($url, $params, "");
    echo "POST请求失败:" . $errMsg;
    return;
}
$log->LogInfo("后台返回结果为>" . $result);
$result_arr = convertStringToArray($result);
printResult($url, $params, $result);
//页面打印请求应答数据
if (!verify($result_arr)) {
    echo "应答报文验签失败<br>\n";
    return;
}
echo "应答报文验签成功<br>\n";
if ($result_arr["respCode"] == "00") {
    //交易已受理,等待接收后台通知更新订单状态,如果通知长时间未收到也可发起交易状态查询
    //TODO
    echo "受理成功。<br>\n";
} else {
    if ($result_arr["respCode"] == "03" || $result_arr["respCode"] == "04" || $result_arr["respCode"] == "05") {
        //后续需发起交易状态查询交易确定交易状态
        //TODO
        echo "处理超时,请稍微查询。<br>\n";
Пример #14
0
                if ($a->result === $b->result) {
                    $result = $a->id - $b->id;
                } else {
                    $result = $a->result - $b->result;
                }
            } else {
                if ($a->result === $b->result) {
                    $result = $b->id - $a->id;
                } else {
                    $result = $b->result - $a->result;
                }
            }
            break;
    }
    return $result;
});
echo printResult($students);
function printResult($data)
{
    $result = "<thead><tr><th>Id</th><th>Username</th><th>Email</th><th>Type</th><th>Result</th></tr></thead>";
    for ($row = 0; $row < count($data); $row++) {
        $result .= "<tr>";
        $result .= "<td>" . htmlspecialchars($data[$row]->id) . "</td>";
        $result .= "<td>" . htmlspecialchars($data[$row]->name) . "</td>";
        $result .= "<td>" . htmlspecialchars($data[$row]->email) . "</td>";
        $result .= "<td>" . htmlspecialchars($data[$row]->type) . "</td>";
        $result .= "<td>" . htmlspecialchars($data[$row]->result) . "</td>";
        $result .= "</tr>";
    }
    return "<table>{$result}</table>";
}
    print "<br/> width: " . $drPublishApiClientImage->getWidth();
    print "<br/> height: " . $drPublishApiClientImage->getHeight();
    print "<br/><br/> photographer (advanced, DrPublishApiClientImage::getDPPhotographer() ";
    print "<pre>";
    print printResult($drPublishApiClientImage->getDPPhotographer());
    print "</pre>";
    print "<hr/>";
}
?>
    <h4>Thumbnails [DrPublishApiWebClientArticleElement
    DrPublishApiWebClientImageElement::getThumbnail(size)]</h4>
        <pre>
<?php 
foreach ($drPublishApiClientImages as $drPublishApiClientImageElement) {
    $drPublishApiClientImage = $drPublishApiClientImageElement->getResizedImage(75);
    print printResult($drPublishApiClientImage);
    print $drPublishApiClientImage;
    print " width=" . $drPublishApiClientImage->getWidth();
    print " src=" . $drPublishApiClientImage->getUrl();
}
?>
        </div>
    </pre>
</div>

<h3>Fact Boxes [DrPublishApiClientList DrPublishApiWebClient::getFactBoxes()]</h3>
<div class="result">
    <div class="content-container"><?php 
print $drPublishApiClientArticle->getFactBoxes();
?>
</div>
        if (isOK($response)) {
            printImageArrayResult($response, " ---- GETTING ITEM FAILED ---- ", " ---- GETTING ITEM SUCCESSFULLY COMPLETED ---- ");
        } else {
            echo $response->getMessage();
        }
        break;
    case "getTrackingDatas":
        echo "Getting trackables..." . PHP_EOL;
        $email = getEMail();
        $password = getPassword();
        $dbName = getDbName();
        $response = getTrackingDatas($email, $password, $dbName);
        if (isOK($response)) {
            printImageArrayResult($response, " ---- GETTING TRACKABLES FAILED ---- ", " ---- GETTING TRACKABLES SUCCESSFULLY COMPLETED ---- ", "trackable");
        } else {
            echo $response->getMessage();
        }
        break;
    case "getStats":
        echo "Getting Stats..." . PHP_EOL;
        $email = getEMail();
        $password = getPassword();
        $dbName = getDbName();
        $response = getStats($email, $password, $dbName);
        if (isOK($response)) {
            printResult($response, " ---- GETTING STATS FAILED ---- ", " ---- GETTING STATS SUCCESSFULLY COMPLETED ---- ", true);
        } else {
            echo $response->getMessage();
        }
        break;
}
Пример #17
0
$filename = __DIR__ . "/../config.php";
require_once $filename;
/*
   Error displaying settings
*/
if (RUN_STATE == "DEBUG") {
    ini_set("display_errors", 'on');
    error_reporting(E_ALL);
} else {
    ini_set("display_errors", 'off');
    error_reporting(0);
}
function printResult($array)
{
    print json_encode($array);
    exit;
}
if (!isset($_POST["access_token"])) {
    printResult(array("error" => "Token not given."));
}
$access_token = $_POST["access_token"];
$ids = array();
unset($config["global"]);
foreach ($config as $page_id => $value) {
    $urlGetPosts = "https://graph.facebook.com/{$page_id}/posts?access_token={$access_token}";
    $feed = json_decode(file_get_contents($urlGetPosts), true);
    $ids[$page_id] = $feed["data"][0]["id"];
}
printResult($ids);
Пример #18
0
    $url = "https://graph.facebook.com/oauth/access_token";
    $url .= "?client_id=" . $app_id;
    $url .= "&client_secret=" . $app_secret;
    $url .= "&grant_type=fb_exchange_token";
    $url .= "&fb_exchange_token=" . $shortToken;
    if (!($res = file_get_contents($url))) {
        printResult(array("code" => 3, "msg" => "Failed requesting the long-lived access token.", "pageid" => $page_id));
    }
    $oldAccessToken = $access_token;
    parse_str($res);
    $newToken = $access_token;
    $access_token = $oldAccessToken;
    if (!is_writable($filename)) {
        printResult(array("code" => 4, "msg" => "config.php is not writable."));
    }
    if (!($contents = file_get_contents($filename))) {
        printResult(array("code" => 5, "msg" => "Could not read the current config."));
    }
    if (!($fp = fopen($filename, 'w'))) {
        printResult(array("code" => 6, "msg" => "Could not open config.php."));
    }
    $find = '$config[$pageid]["access_token"] = "' . $oldAccessToken . '";';
    $replace = '$config[$pageid]["access_token"] = "' . $newToken . '";';
    $contents = str_replace($find, $replace, $contents);
    if (fwrite($fp, $contents) === false) {
        printResult(array("code" => 7, "msg" => "Could not write the new config to the config file."));
    }
    fclose($fp);
}
printResult(array("code" => 0, "msg" => "All tokens updated."));
Пример #19
0
<?php

require_once '../php/sql.php';
require_once '../php/print/printHeaders.php';
require_once '../php/print/printResult.php';
require_once '../php/print/printFunction.php';
require_once '../php/print/printFooter.php';
require_once '../php/print/printSummary.php';
require_once '../php/definedQuery.php';
require_once '../php/update.php';
?>

 <?php 
updateCatchable();
updateOwned();
updatePrice();
?>

 <?php 
echo printResult();
Пример #20
0
}
function disconnect($db_connection)
{
    mysql_close($db_connection);
}
?>

<html>
<head><title>Query</title></head>
<body>
<form action="" method="POST">
<textarea name="query" cols="60" rows="8"></textarea>
<br />
<input type="submit" value="Submit" />
</form>
<br />
</body>
</html>

<?php 
if (isset($_POST) && isset($_POST["query"])) {
    $db_connection = connect();
    if (!$db_connection) {
        $errmsg = mysql_error($db_connection);
        echo "Connection failed:" . $errmsg . "<br />";
        exit(1);
    }
    $rs = query($_POST["query"], $db_connection);
    printResult($rs);
    disconnect($db_connection);
}
Пример #21
0
                $alltuples = array($tuple);
                executeBoundSQL("update tab1 set name=:bind2 where name=:bind1", $alltuples);
                OCICommit($db_conn);
            } else {
                if (array_key_exists('dostuff', $_POST)) {
                }
            }
        }
    }
    if ($_POST && $success) {
        //POST-REDIRECT-GET -- See http://en.wikipedia.org/wiki/Post/Redirect/Get
        header("location: oracle-test.php");
    } else {
        // Select data...
        $result = executePlainSQL("select * from Customer");
        printResult($result);
    }
    //Commit to save changes...
    OCILogoff($db_conn);
} else {
    echo "cannot connect";
    $e = OCI_Error();
    // For OCILogon errors pass no handle
    echo htmlentities($e['message']);
}
/* OCILogon() allows you to log onto the Oracle database
   The three arguments are the username, password, and database
   You will need to replace "username" and "password" for this to
   to work. 
   all strings that start with "$" are variables; they are created
   implicitly by appearing on the left hand side of an assignment 
Пример #22
0
                }
            }
            if (isset($res_obj->error)) {
                terminate($result, true);
            } else {
                printResult($phone_numbers);
            }
            break;
        case 'get_participants':
            $required_params = array('conference_id');
            if (count(array_intersect_key(array_flip($required_params), $data)) === count($required_params)) {
                $Result = $db->query("SELECT * FROM conferences WHERE id = ? AND manager_id = ?", array($data['conference_id'], $_SESSION['manager_id']));
                $Conferences = $Result->fetchALL();
                if (sizeof($Conferences) > 0) {
                    $Result = $db->query("SELECT * FROM participants WHERE conference_id = ?", array($data['conference_id']));
                    $Participants = $Result->fetchALL();
                    printResult(array("participants" => $Participants, "conference" => $Conferences[0]));
                } else {
                    terminate("No conference found");
                }
            } else {
                terminate("Required params not specified");
            }
            break;
        default:
            # code...
            break;
    }
} else {
    terminate("No action type specified");
}
Пример #23
0
$map = \sclable\arrayFunctions\ArrayWrap::create([]);
$wrapMap = \sclable\arrayFunctions\ArrayWrap::create([]);
for ($i = 0; $i < 100; $i++) {
    // foreach
    $fTextList = $textList;
    $start = microtime(true);
    foreach ($fTextList as &$text) {
        $text = htmlentities($text);
    }
    $end = microtime(true);
    $foreach->push($end - $start);
    // map
    $wTextList = $textList;
    $start = microtime(true);
    $wTextList = array_map('htmlentities', $wTextList);
    $end = microtime(true);
    $map->push($end - $start);
    // ArrayWrap map
    $mTextList = $textList;
    $start = microtime(true);
    $mTextList = \sclable\arrayFunctions\ArrayWrap::create($mTextList)->apply('htmlentities');
    $end = microtime(true);
    $wrapMap->push($end - $start);
}
echo 'foreach: ' . printResult($foreach) . PHP_EOL;
echo 'map: ' . printResult($map) . PHP_EOL;
echo 'wrapMap: ' . printResult($wrapMap) . PHP_EOL;
function printResult(\sclable\arrayFunctions\ArrayWrap $results)
{
    return "min: {$results->min()} / max: {$results->max()} / avg: {$results->avg()} || sum: {$results->sum()}";
}
Пример #24
0
    function printResult($result)
    {
        //prints results from a select statement
        echo "<br>Employee Info<br>";
        echo "<table class='table table-striped'>";
        echo "<tr><th>Username</th>" . " " . "<th>Wage</th>" . " " . "<th>Job Type</th>" . " " . "<th>Work Schedule</th></tr>";
        while ($row = OCI_Fetch_Array($result, OCI_BOTH)) {
            echo "<tr><td>" . $row["USERNAME"] . " </td><td>" . $row["WAGE"] . " </td><td>" . $row["JOBT"] . "</td><td>" . " " . $row["WORKS"] . "</td></tr>";
            //or just use "echo $row[0]"
        }
        echo "</table>";
    }
    // Connect Oracle...
    if ($db_conn) {
        $users = $_SESSION["username"];
        printResult(executePlainSQL("select * from employee where username = '******'"));
        OCICommit($db_conn);
    }
    ?>
        </font>
      </div>
    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="../js/bootstrap.min.js"></script>
  </body>
<?php 
} else {
    echo "ACCESS DENIED";
}
Пример #25
0
require_once "iwiwconnecthelper.php";
// the application consumerKey and consumerSecret
$consumerKey = 'kulcs';
$consumerSecret = 'titkos_kulcs';
// iwiw url eg. sandbox.iwiw.hu, iwiw.hu
$iwiwBaseURL = 'http://sandbox.iwiw.hu';
// iwiw Api url eg. api.sandbox.iwiw.hu, api.iwiw.hu
$iwiwBaseApiURL = 'http://api.sandbox.iwiw.hu';
$osapi = initIWIWConnect($consumerKey, $consumerSecret, $iwiwBaseURL, $iwiwBaseApiURL);
if (osapi) {
    $result = getSelfAndFriends($osapi);
    printResult("<h2>Friend List</h2>", $result);
    $result = createActivity($osapi, 'testtitle', 'testvalue ' . time());
    printResult("<h2>Create Activity</h1>", $result);
    $result = createMessage($osapi, array(9612288), 'testbody' . time());
    printResult("<h2>Create Message</h1>", $result);
} else {
    echo "Error connecting to IWIW !";
}
function printResult($header, $result)
{
    echo $header;
    foreach ($result as $key => $result_item) {
        if ($result_item instanceof osapiError) {
            $code = $result_item->getErrorCode();
            $message = $result_item->getErrorMessage();
            echo "<h3>There was a <em>{$code}</em> error with the <em>{$key}</em> request:</h3>";
            echo "<pre>";
            echo htmlentities($message);
            echo "</pre>";
        } else {
Пример #26
0
 printResult("origin", "Origin", $origin, "input");
 printResult("provenance", "Provenance", $provenance, "input");
 printResult("place_of_composition", "Place of Composition", $place_of_composition, "input");
 printResult("shelfmark", "Shelfmark", $shelfmark, "input");
 printResult("freeculture", "Freeculture", $freeculture, "radio");
 printResult("full_text_url", "Full text URL", $full_text_url, "input");
 printResult("full_text_plain", "Full text", $full_text_plain, "textarea");
 printResult("is_full_text", "Fulltext", $is_full_text, "radio");
 printResult("image_url", "Image URL", $image_url, "input");
 printResult("source", "Source", $source, "input");
 printResult("metadata_xml_url", "XML Metadata URL", $metadata_xml_url, "input");
 printResult("metadata_html_url", "HTML Metadata URL", $metadata_html_url, "input");
 printResult("text_divisions", "Divisions of the Text", $text_divisions, "textarea");
 printResult("ocr", "OCR", $ocr, "radio");
 printResult("thumbnail_url", "Thumbnail URL", $thumbnail_url, "input");
 printResult("notes", "Notes", $notes, "textarea");
 // This is literally the worst.
 /* 7/29/15 - Removed until MySQLnd is installed onto Lichen.
    <?php foreach ($row as $key=>$value): ?>
      <?php switch ($objectsTableInputTypes[$key]): case "text": // Need a reason as to why PHP can be stupid? Any trailing whitespace between switch and the first case throws an error. http://php.net/manual/en/control-structures.alternative-syntax.php ?>
        <section class="form-group">
          <label for="<?php print $key; ?>" class="control-label col-xs-2"><?php print $objectsTableColumDisplayNames[$key]; ?></label>
          <div class="col-xs-10">
            <input type="text" class="form-control" name="<?php print $key; ?>" id="<?php print $key; ?>" value="<?php print $value; ?>"<?php printRequired($key); ?>>
          </div>
        </section>
        <hr>
        <?php break; ?>
        <?php case "textarea": ?>
        <section class="form-group">
          <label for="<?php print $key; ?>" class="control-label col-xs-2"><?php print $objectsTableColumDisplayNames[$key]; ?></label>
Пример #27
0
                $additional = array($i, 0);
                if (!$is_requests) {
                    $additional[] = SpeedIndex($testPath, $i, 0, $testInfo);
                }
                csvFile("{$testPath}/{$i}_{$fileType}", null, $column_count, $additional);
                $additional = array($i, 1);
                if (!$is_requests) {
                    $additional[] = SpeedIndex($testPath, $i, 1, $testInfo);
                }
                csvFile("{$testPath}/{$i}_Cached_{$fileType}", null, $column_count, $additional);
            }
        } else {
            csvPageData($id, $testPath, $test['test']['runs']);
        }
    }
    printResult();
} else {
    header("HTTP/1.0 404 Not Found");
}
function csvPageData($id, $testPath, $runs)
{
    if ($_GET['requests']) {
        for ($i = 1; $i <= $runs; $i++) {
            for ($cached = 0; $cached <= 1; $cached++) {
                $requests = getRequests($id, $testPath, $i, $cached, $secure, $loc, false);
                if (isset($requests) && is_array($requests) && count($requests)) {
                    foreach ($requests as &$row) {
                        csvArray($row, $id, $i, $cached);
                    }
                }
            }
Пример #28
0
        return $result;
    }
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Home5</title>
	</head>
	<body>
		<?php 
if ($_REQUEST) {
    ?>
			<?php 
    echo printResult($_REQUEST);
    ?>
		<?php 
}
?>
		<form action="" method="post">
			<div>
				<label>Име</label>
				<input type="text" name="name">
			</div>
			<div>
				<label>Фамилия</label>
				<input type="text" name="lastName">
			</div>
			<div>
				<label>Години</label>
//   string(15) "54.239.128.0/18"
//   [5]=>
//   string(15) "54.239.192.0/19"
if ($argc > 1 && $argv[1]) {
    // This means we have command-line args
    foreach ($argv as $test_ip) {
        if ($test_ip == $argv[0]) {
            continue;
        }
        // $argv[ 0 ] is the name of this script, so skip it
        if ($test_ip == "") {
            continue;
        }
        // Don't know how we'd get a null arg, but just in case skip it
        printResult($test_ip, $OK_CIDRs);
    }
} else {
    // If we didn't get command-line args, assume we have STDIN. (Just like 'grep' if there's no args _and_ no STDIN, how can you tell?)
    while (!feof(STDIN)) {
        $test_line = rtrim(fgets(STDIN));
        // Trim off EOL
        if ($test_line == "") {
            continue;
        }
        // Skip a blank line
        foreach (preg_split("/[\\s,]+/", $test_line) as $test_ip) {
            // In case we have multiple addresses per line, handle each one
            printResult($test_ip, $OK_CIDRs);
        }
    }
}
function employeePage()
{
    // User is not logging out
    if (!isset($_POST['logout_button'])) {
        $name = $_SESSION['username'];
        print "<div style='text-align:right'>Welcome {$name} </div>";
        //Separate Form, Logout button would be prioritized for enter after typing into fields.
        print "<form method=\"POST\">";
        print "<div align=\"right\"><input type=\"submit\" name=\"logout_button\" value=\"Logout\" /></div>";
        print "</form>";
        // open connection
        $con = mysqli_connect($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
        $result = NULL;
        // handle various different buttons
        if (isset($_POST['addButton'])) {
            // Generate a unique employee id
            $EmpID;
            $temp_result;
            do {
                $empID = rand(10000000, 99999999);
                $temp_result = mysqli_query($con, "SELECT * FROM `employees` WHERE `Employee_ID`=" . $empID);
            } while (mysqli_fetch_array($temp_result) == TRUE);
            // Display text boxes
            print "<h1>Add New Employee</h1>";
            print "</br><form method=\"POST\"><div align=\"left\">";
            print "Employee ID: " . $empID;
            print "<input name=\"id\" type=\"hidden\" value=" . $empID . " /> </br>";
            print "First Name: <input name=\"first\" type=\"text\" /></br>";
            print "Last Name: <input name=\"last\" type=\"text\" /> </br>";
            print "Gender (M/F): <input name=\"gender\" type=\"text\" maxlength=\"1\" size=\"1\" /> </br>";
            print "Date Started: <input name=\"s_year\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"YYYY\" /> - " . "<input name=\"s_month\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"MM\" /> - " . "<input name=\"s_day\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"DD\" /> </br>";
            print "Date Ended: <input name=\"e_year\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"YYYY\" /> - " . "<input name=\"e_month\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"MM\" /> - " . "<input name=\"e_day\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"DD\" /> </br>";
            print "Social Security Number: <input name=\"ssn1\" type=\"text\" maxlength=\"3\" size=\"3\" placeholder=\"123\" /> - " . "<input name=\"ssn2\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"45\" /> - " . "<input name=\"ssn3\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"6789\" /> </br>";
            print "Bank Number: <input name=\"bank\" type=\"text\" maxlength=\"9\" size=\"9\" /> </br>";
            print "Address: <input name=\"address\" type=\"text\" /> </br>";
            print "Phone Number (<input name=\"phone1\" type=\"text\" maxlength=\"3\" size=\"3\" placeholder=\"000\" />) " . "<input name=\"phone2\" type=\"text\" maxlength=\"3\" size=\"3\" placeholder=\"123\" /> - " . "<input name=\"phone3\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"4567\" /> </br>";
            print "<input type=\"submit\" name=\"createSubmit\" value=\"Submit\" />";
            print "<input type=\"submit\" name=\"cancel\" value=\"Cancel\" /></div></form>";
            print "<hr></br>";
        } elseif (isset($_POST['createSubmit'])) {
            // format date, ssn and phone number for insertion
            $start = $_POST['s_year'] . "-" . $_POST['s_month'] . "-" . $_POST['s_day'];
            $end = $_POST['e_year'] . "-" . $_POST['e_month'] . "-" . $_POST['e_day'];
            $ssn = $_POST['ssn1'] . "-" . $_POST['ssn2'] . "-" . $_POST['ssn3'];
            $phone = "(" . $_POST['phone1'] . ") " . $_POST['phone2'] . "-" . $_POST['phone3'];
            // generate username and password from name
            $userpass = $_POST['last'] . $_POST['first'][0];
            $query1 = "INSERT INTO `employees`(`Employee_ID`, `First_Name`, `Last_Name`, `Gender`, ";
            $query1 .= "`Date_Started_Employment`, `Date_Left_Employment`) VALUES ('" . $_POST['id'] . "', '" . $_POST['first'] . "', '" . $_POST['last'];
            $query1 .= "', '" . $_POST['gender'] . "', '" . $start . "', '" . $end . "')";
            $query2 = "INSERT INTO `employee_private`(`Employee_ID`, `Employee_Username`, `Employee_Password`, ";
            $query2 .= "`Employee_SSN`, `Employee_Bank`, `Employee_Address`, `Employee_Phone`) VALUES ";
            $query2 .= "('" . $_POST['id'] . "', '" . $userpass . "', '" . $userpass . "', '" . $ssn . "', '" . $_POST['bank'];
            $query2 .= "', '" . $_POST['address'] . "', '" . $phone . "')";
            if (mysqli_query($con, $query1) && mysqli_query($con, $query2)) {
                print "Successfully Created Information. </BR>";
            } else {
                print mysqli_error($con) . "</BR>";
                print "Error! Unsuccessful Creation.</BR>";
            }
        } elseif (isset($_POST['editButton'])) {
            $result1 = mysqli_query($con, "Select * FROM `employees` WHERE `Employee_ID`='" . $_POST['editButton'] . "'");
            $result2 = mysqli_query($con, "Select * FROM `employee_private` WHERE `Employee_ID`='" . $_POST['editButton'] . "'");
            if (($info1 = mysqli_fetch_array($result1)) && ($info2 = mysqli_fetch_array($result2))) {
                // prepare dates, ssn and phone numbers for multiple html text boxes
                $start = $info1['Date_Started_Employment'];
                $s_year = substr($start, 0, 4);
                $s_month = substr($start, 5, 2);
                $s_day = substr($start, 8, 2);
                $end = $info1['Date_Left_Employment'];
                $e_year = substr($end, 0, 4);
                $e_month = substr($end, 5, 2);
                $e_day = substr($end, 8, 2);
                $ssn = $info2['Employee_SSN'];
                $ssn1 = substr($ssn, 0, 3);
                $ssn2 = substr($ssn, 4, 2);
                $ssn3 = substr($ssn, 7, 4);
                $phone = $info2['Employee_Phone'];
                $phone1 = substr($phone, 1, 3);
                $phone2 = substr($phone, 6, 3);
                $phone3 = substr($phone, 10, 4);
                print "<h1>Edit Employee</h1>";
                print "</br><form method=\"POST\"><div align=\"left\">";
                print "Employee ID: " . $info1['Employee_ID'];
                print "<input name=\"id\" type=\"hidden\" value=" . $info1['Employee_ID'] . " /> </br>";
                print "First Name: <input name=\"first\" type=\"text\" value=\"" . $info1['First_Name'] . "\" /> </br>";
                print "Last Name: <input name=\"last\" type=\"text\" value=\"" . $info1['Last_Name'] . "\" /> </br>";
                print "Gender (M/F): <input name=\"gender\" type=\"text\" maxlength=\"1\" size=\"1\" value=\"" . $info1['Gender'] . "\" /> </br>";
                print "Date Started: <input name=\"s_year\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"YYYY\" value=\"" . $s_year . "\" /> - " . "<input name=\"s_month\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"MM\" value=\"" . $s_month . "\" /> - " . "<input name=\"s_day\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"DD\" value=\"" . $s_day . "\" /> </br>";
                print "Date Ended: <input name=\"e_year\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"YYYY\" value=\"" . $e_year . "\" /> - " . "<input name=\"e_month\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"MM\" value=\"" . $e_month . "\" /> - " . "<input name=\"e_day\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"DD\" value=\"" . $e_day . "\" /> </br>";
                print "Social Security Number: <input name=\"ssn1\" type=\"text\" maxlength=\"3\" size=\"3\" placeholder=\"123\" value=\"" . $ssn1 . "\" /> - " . "<input name=\"ssn2\" type=\"text\" maxlength=\"2\" size=\"2\" placeholder=\"45\" value=\"" . $ssn2 . "\" /> - " . "<input name=\"ssn3\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"6789\" value=\"" . $ssn3 . "\" /> </br>";
                print "Bank Number: <input name=\"bank\" type=\"text\" maxlength=\"9\" size=\"9\" value=\"" . $info2['Employee_Bank'] . "\" /> </br>";
                print "Address: <input name=\"address\" type=\"text\" value=\"" . $info2['Employee_Address'] . "\" /> </br>";
                print "Phone Number (<input name=\"phone1\" type=\"text\" maxlength=\"3\" size=\"3\" placeholder=\"000\" value=\"" . $phone1 . "\" />) " . "<input name=\"phone2\" type=\"text\" maxlength=\"3\" size=\"3\" placeholder=\"123\" value=\"" . $phone2 . "\" /> - " . "<input name=\"phone3\" type=\"text\" maxlength=\"4\" size=\"4\" placeholder=\"4567\" value=\"" . $phone3 . "\" /> </br>";
                print "<input type=\"submit\" name=\"editSubmit\" value=\"Submit\" />";
                print "<input type=\"submit\" name=\"cancel\" value=\"Cancel\" /></div></form>";
                print "<hr></br>";
            }
        } elseif (isset($_POST['editSubmit'])) {
            // prepare dates, ssn and phone number
            $start = $_POST['s_year'] . "-" . $_POST['s_month'] . "-" . $_POST['s_day'];
            $end = $_POST['e_year'] . "-" . $_POST['e_month'] . "-" . $_POST['e_day'];
            $ssn = $_POST['ssn1'] . "-" . $_POST['ssn2'] . "-" . $_POST['ssn3'];
            $phone = "(" . $_POST['phone1'] . ") " . $_POST['phone2'] . "-" . $_POST['phone3'];
            //prepare update query for employees table
            $query1 = "UPDATE `employees` SET `First_Name`='" . $_POST['first'] . "',`Last_Name`='" . $_POST['last'] . "'";
            $query1 .= ",`Gender`='" . $_POST['gender'] . "',`Date_Started_Employment`='" . $start . "'";
            $query1 .= ",`Date_Left_Employment`='" . $end . "' WHERE `Employee_ID`='" . $_POST['id'] . "'";
            //prepare update query for employee_private table
            $query2 = "UPDATE `employee_private` SET `Employee_SSN`='" . $ssn . "',`Employee_Bank`='" . $_POST['bank'] . "',";
            $query2 .= "`Employee_Address`='" . $_POST['address'] . "',`Employee_Phone`='" . $phone . "' WHERE `Employee_ID`='" . $_POST['id'] . "'";
            if (mysqli_query($con, $query1) && mysqli_query($con, $query2)) {
                print "Successfully Edited Information. </BR>";
            } else {
                print mysqli_error($con) . "</BR>";
                print "Error! Unsuccessful Edit.</BR>";
            }
        } elseif (isset($_POST['cancel'])) {
        } elseif (isset($_POST['deleteButton'])) {
            if (mysqli_query($con, "DELETE FROM employees WHERE `Employee_ID`='" . $_POST['deleteButton'] . "'") == TRUE) {
                print "Employee with ID " . $_POST['deleteButton'] . " has been removed. <BR>";
            }
        }
        // Create search bar and drop down for category of search
        print "<h1>Employee Database</h1>";
        print "<form method=\"POST\">";
        print "Search By: </br>";
        print "<select name=\"formChoice\"> ";
        print "<option value=\"\">Select</option>";
        print "<option value=\"Employee_ID\">ID</option>";
        print "<option value=\"First_Name\">First Name</option>";
        print "<option value=\"Last_Name\">Last Name</option>";
        print "<option value=\"Gender\">Gender</option>";
        print "<option value=\"Date_Started_Employment\">Start Date</option>";
        print "<option value=\"Date_Left_Employment\">Left Date</option></select>";
        print "<input type=\"text\" name=\"Value\">";
        print "<input type=\"submit\" name=\"query_submit\" value=\"Submit\" default/>";
        print "<input type=\"submit\" name=\"query_submit\" value=\"Reset\" default/>";
        print "</form>";
        print "<div align=\"left\"><form method=\"POST\"><input type=\"submit\" name=\"addButton\" value=\"Add A New Employee\"></form></div>";
        // Logout and Reset button not pressed and form dropdown is not 'select' on employee page
        if (isset($_POST['query_submit']) && $_POST['query_submit'] != "Reset" && isset($_POST['formChoice']) && $_POST['formChoice'] != "" && isset($_POST['Value'])) {
            $formChoice = $_POST['formChoice'];
            $value = $_POST['Value'];
            print "SELECT * FROM employees WHERE {$formChoice}='{$value}'";
            $result = mysqli_query($con, "SELECT * FROM employees WHERE {$formChoice}='{$value}'");
            printResult($result);
        } else {
            print "SELECT * FROM Employees<BR>";
            $result = mysqli_query($con, "(SELECT * FROM employees)");
            printResult($result);
        }
        //closing the connection
        mysqli_close($con);
    } else {
        session_unset();
        session_destroy();
        print "You have been logged out.";
        loginPage();
    }
}