示例#1
0
function printRecord($l)
{
    global $propCount, $propTotal;
    $tpl = Template::getInstance();
    $totalTicks = $tpl->masterHandler->{$propCount};
    $totalTime = $tpl->masterHandler->{$propTotal};
    $total = (int) $l->{$propTotal};
    $count = (int) $l->{$propCount};
    if ($count === 0) {
        return;
    }
    $avg = round($total / $count / 1000000, 4);
    $tickAvg = round($avg * ($count / $totalTicks), 4);
    $totalPct = round($total / $totalTime * 100, 2);
    if ($l->id->name === "Full Server Tick") {
        // always 100%
        $totalPct = pctView($totalPct, 200, 200, 200, 200);
        $pctOfTick = pctView($tickAvg / 50 * 100, 90, 80, 75, 70);
    } else {
        $totalPct = pctViewMod($totalPct, $totalPct / ($tickAvg / 50 * 100), 50, 30, 20, 10);
        $pctOfTick = pctView($tickAvg / 50 * 100, 50, 30, 20, 10);
    }
    $avgCountTick = number_format($count / $totalTicks, 2);
    $tickAvg = pctView($tickAvg);
    $avg = pctView($avg);
    $name = cleanName($l->id);
    $total = round($total / 1000000000, 3);
    echo "\n<div class='row-wrap'>\n\t<div class='name' style>{$name}</div>\n\n\t<div class='row-info'>\n\n\t\t<div class='row-info-total'>count(<span class='count'>{$count}</span>)\n\t\ttotal(<span class='totalPct'>{$totalPct}%</span> <span class='totalTime'>{$total}s</span>, <span class='pctOfTick'>{$pctOfTick}% of tick</span>)\n\t\t</div>\n\n\t\t<div class='row-info-avg'>\n\t\tavg(<span class='avgMs'>{$avg}ms</span> per - <span class='tickAvgMs'>{$tickAvg}ms/{$avgCountTick} per tick</span>)\n\t\t</div>\n\n\t</div>\n</div>\n\t\t\n";
}
示例#2
0
function printRecord($l, $depth = 0)
{
    static $i;
    $tpl = Template::getInstance();
    $lagTicks = $tpl->masterHandler->lagCount;
    $ticks = $tpl->masterHandler->count;
    $totalTime = $tpl->masterHandler->total;
    $lagTotalTime = $tpl->masterHandler->lagTotal;
    $id = $l->id->id . "_" . $i++;
    $total = LAG_ONLY ? $l->lagTotal : $l->total;
    $count = LAG_ONLY ? $l->lagCount : $l->count;
    $avg = round($total / $count / 1000000, 4);
    $tickAvg = round($avg * ($count / (LAG_ONLY ? $lagTicks : $ticks)), 4);
    $tickAvg = lagView($tickAvg);
    $totalPct = round($total / (LAG_ONLY ? $lagTotalTime : $totalTime) * 100, 2);
    if ($l->id->name == "Full Server Tick") {
        // always 100%
        $totalPct = lagView($totalPct, 200, 200, 200, 200);
    } else {
        $totalPct = lagView($totalPct, 25, 15, 7, 3);
    }
    $avg = lagView($avg);
    $name = cleanName($l->id);
    $total = round($total / 1000000000, 3);
    $indents = "";
    for ($j = 1; $j <= $depth; $j++) {
        $num = $j % 5;
        $indents .= "<div class='indent depth{$num} full-depth{$j}'></div>";
    }
    echo "<div class='full-timing-row'>{$indents}<div id='{$id}' class='timing-row'>\n\t\t<a href='#{$id}'>#</a><span class='name'>{$name}</span> - count(<span class='count'>{$count}</span>) -\n\t\ttotal(<span class='totalPct'>{$totalPct}%</span> <span class='totalTime'>{$total}s</span>) -\n\t\tavg(<span class='avgMs'>{$avg}ms</span> - <span class='tickAvgMs'>{$tickAvg}ms</span>)\n\t\t</div></div>\n";
}
function getEnumClass($enumDefinition, $columnName)
{
    $eClass = "class db_enum_" . $columnName . " { function __construct() {}";
    $enumVals = explode(",", str_ireplace("'", "", str_ireplace(")", "", str_ireplace("(", "", str_ireplace("enum", "", $enumDefinition)))));
    foreach ($enumVals as &$value) {
        $eClass .= " const c_" . cleanName($value) . "='" . $value . "';";
    }
    $eClass .= " }";
    return $eClass;
}
示例#4
0
文件: index.php 项目: uptonic/Moopix
            if ($image->getAttribute('data-extension') == "mov") {
                $fxlt_image->assign('IMAGE_THUMB_SRC', $mov_thumb);
                $fxlt_image->assign('IMAGE_REL', 'video');
            } else {
                $fxlt_image->assign('IMAGE_THUMB_SRC', resize($image_src, $resize_settings));
                $fxlt_image->assign('IMAGE_REL', 'lightbox');
            }
        }
        // Append image to page
        $fxlt->assign('image', $fxlt_image);
        // Clear the buffer
        $fxlt_image->clear();
    }
}
/* General template settings
---------------------------------------------------*/
// Set current URL params for filter links
$fxlt->assign('THIS_ALBUM_ID', $alb);
$fxlt->assign('THIS_CATEGORY_ID', $cat);
// Assign the currently-viewed album a title
$fxlt->assign('THIS_PAGE_TITLE', cleanName($protos->getAlbumName()) . " - " . cleanName($protos->getCategoryName()));
$fxlt->assign('THIS_ALBUM_NAME', $protos->getAlbumName());
$fxlt->assign('THIS_ALBUM_TITLE', cleanName($protos->getAlbumName()));
$fxlt->assign('THIS_CATEGORY_NAME', $protos->getCategoryName());
$fxlt->assign('THIS_CATEGORY_TITLE', cleanName($protos->getCategoryName()));
$fxlt->assign('THIS_SET_NAME', $protos->getSetName());
$fxlt->assign('THIS_SET_DESCRIPTION', $protos->getSetDescription());
/* Display template
---------------------------------------------------*/
// Write to page
$fxlt->display();
示例#5
0
function getvnum($wk, $vendor, $cost)
{
    global $lkp;
    $vnum = 0;
    $cv = cleanName($vendor);
    if ($wk == 1) {
        if ($cost > 0) {
            if (in_array($cv, $lkp["1," . $wk . ",3"]) || in_array($cv, $lkp["1," . $wk . ",4"]) || in_array($cv, $lkp["1," . $wk . ",5"]) || in_array($cv, $lkp["1," . $wk . ",6"])) {
                $vnum = 1;
            } else {
                if (in_array($cv, $lkp["2," . $wk . ",3"]) || in_array($cv, $lkp["2," . $wk . ",4"]) || in_array($cv, $lkp["2," . $wk . ",5"]) || in_array($cv, $lkp["2," . $wk . ",6"])) {
                    $vnum = 2;
                } else {
                    if (in_array($cv, $lkp["3," . $wk . ",3"]) || in_array($cv, $lkp["3," . $wk . ",4"]) || in_array($cv, $lkp["3," . $wk . ",5"]) || in_array($cv, $lkp["3," . $wk . ",6"])) {
                        $vnum = 3;
                    } else {
                        if (in_array($cv, $lkp["4," . $wk . ",3"]) || in_array($cv, $lkp["4," . $wk . ",4"]) || in_array($cv, $lkp["4," . $wk . ",5"]) || in_array($cv, $lkp["4," . $wk . ",6"])) {
                            $vnum = 4;
                        }
                    }
                }
            }
        }
    } else {
        if ($wk == 2) {
            if ($cost > 0) {
                if (in_array($cv, $lkp["1," . $wk . ",3"]) || in_array($cv, $lkp["1," . $wk . ",4"]) || in_array($cv, $lkp["1," . $wk . ",5"]) || in_array($cv, $lkp["1," . $wk . ",6"])) {
                    $vnum = 1;
                } else {
                    if (in_array($cv, $lkp["2," . $wk . ",3"]) || in_array($cv, $lkp["2," . $wk . ",4"]) || in_array($cv, $lkp["2," . $wk . ",5"]) || in_array($cv, $lkp["2," . $wk . ",6"])) {
                        $vnum = 2;
                    } else {
                        if (in_array($cv, $lkp["3," . $wk . ",3"]) || in_array($cv, $lkp["3," . $wk . ",4"]) || in_array($cv, $lkp["3," . $wk . ",5"]) || in_array($cv, $lkp["3," . $wk . ",6"])) {
                            $vnum = 3;
                        } else {
                            if (in_array($cv, $lkp["4," . $wk . ",3"]) || in_array($cv, $lkp["4," . $wk . ",4"]) || in_array($cv, $lkp["4," . $wk . ",5"]) || in_array($cv, $lkp["4," . $wk . ",6"])) {
                                $vnum = 4;
                            }
                        }
                    }
                }
            }
        } else {
            if ($wk == 3) {
                if ($cv != "") {
                    if (in_array($cv, $lkp["1," . $wk . ",3"]) || in_array($cv, $lkp["1," . $wk . ",4"]) || in_array($cv, $lkp["1," . $wk . ",5"]) || in_array($cv, $lkp["1," . $wk . ",6"])) {
                        $vnum = 1;
                    } else {
                        if (in_array($cv, $lkp["2," . $wk . ",3"]) || in_array($cv, $lkp["2," . $wk . ",4"]) || in_array($cv, $lkp["2," . $wk . ",5"]) || in_array($cv, $lkp["2," . $wk . ",6"])) {
                            $vnum = 2;
                        } else {
                            if (in_array($cv, $lkp["3," . $wk . ",3"]) || in_array($cv, $lkp["3," . $wk . ",4"]) || in_array($cv, $lkp["3," . $wk . ",5"]) || in_array($cv, $lkp["3," . $wk . ",6"])) {
                                $vnum = 3;
                            } else {
                                if (in_array($cv, $lkp["4," . $wk . ",3"]) || in_array($cv, $lkp["4," . $wk . ",4"]) || in_array($cv, $lkp["4," . $wk . ",5"]) || in_array($cv, $lkp["4," . $wk . ",6"])) {
                                    $vnum = 4;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // echo '<br>'.$cv.' - '.$vnum.' = '.$cost;
    return $vnum;
}
示例#6
0
        $app->notFound();
    }
})->name('source');
// show html
$app->get('/:name/html/:id', function ($name, $id) use($app, $mailbox) {
    $email = $mailbox->getMail($id);
    if (!is_null($email)) {
        $html_safe = preg_replace("/https?:\\/\\//i", URI_REDIRECT_PREFIX . '\\0', $email->textHtml);
        print $html_safe;
    } else {
        $app->notFound();
    }
})->name('html');
// read emails
$app->get('/:name/', function ($name) use($app, $mailbox) {
    $name = cleanName($name);
    $mailsIds = findMails($name, $mailbox);
    $emails = array();
    foreach ($mailsIds as $id) {
        $emails[] = $mailbox->getMail($id);
    }
    $address = $name . '@' . DOMAIN;
    if ($emails === NULL || count($emails) == 0) {
        $app->render('waiting.html', array('name' => $name, 'address' => $address));
    } else {
        $app->render('list.html', array('name' => $name, 'address' => $address, 'emails' => $emails));
    }
})->name('read');
$app->run();
function cleanName($name)
{
<?php

include 'util.php';
$string = file_get_contents("../conf/conf.json");
$json_a = json_decode($string, true);
$host = $json_a['datasource']['host'];
$user = $json_a['datasource']['username'];
$pass = $json_a['datasource']['password'];
$db = $json_a['datasource']['database'];
$con = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}") or die("Could not connect to server\n");
$table = $_GET['table'];
$query = "SELECT * FROM " . $table;
$rs = pg_query($con, $query) or die("Cannot execute query: {$query}\n");
$players = array();
//key: player, value: array -> key: award, value: count
while ($row = pg_fetch_assoc($rs)) {
    $p = null;
    $player1Name = $row['player1'];
    //clean
    $player1Name = cleanName($player1Name);
    if (!array_key_exists($player1Name, $players)) {
        $players[$player1Name] = array();
    }
    $players[$player1Name][cleanName($row['player2'])] = array("kills" => $row['kills'], "deaths" => $row['deaths']);
}
pg_close($con);
echo json_encode($players);
示例#8
0
<?php

/**
*	Script generating all possible emails for a said person
*	Doesn't include reverted emails (last.first @ example.com)
**/
$options = getopt("f:l:d:");
$first = strtolower(trim($options["f"]));
$last = strtolower(trim($options["l"]));
$domain = strtolower(trim($options["d"]));
$emails = [];
$allFirsts = cleanName($first);
$allLasts = cleanName($last);
//Full name
foreach ($allFirsts as $fname) {
    foreach ($allLasts as $lname) {
        $emails[] = $fname . "." . $lname . "@" . $domain;
        $emails[] = $fname . "_" . $lname . "@" . $domain;
        $emails[] = $fname . "-" . $lname . "@" . $domain;
        $emails[] = $fname . $lname . "@" . $domain;
    }
}
//First name
foreach ($allFirsts as $fname) {
    $emails[] = $fname . "@" . $domain;
}
//Last name
foreach ($allLasts as $fname) {
    $emails[] = $lname . "@" . $domain;
}
$aFindex = count($allFirsts) - 1;
示例#9
0
        $qtable = "";
        ?>
    <div class="properties <?php 
        if ($this->hidedescription) {
            echo 'hideProperties';
        }
        ?>
">
    <?php 
        if ($this->properties) {
            foreach ($this->properties as $r) {
                ?>
      <div class="searchresult panel">
      <div class="itemhead">
      <a href="a/data-qualities/<?php 
                echo cleanName($r->{'quality'});
                ?>
" class="iconpurple">
      <i class="fa fa-fw fa-bar-chart"></i> <?php 
                echo $r->{'quality'};
                ?>
</a>
      </div>
      <div class="dataproperty"><?php 
                if (is_numeric($r->{'value'})) {
                    echo round($r->{'value'}, 2);
                } elseif ($r->{'value'} == 'true') {
                    echo "<i class='fa fa-check fa-lg'></i>";
                } elseif ($r->{'value'} == 'false') {
                    echo "<i class='fa fa-times fa-lg'></i>";
                } else {
示例#10
0
    foreach ($this->flow['parameters'] as $r) {
        echo "<tr><td>" . $r['name'] . "</td><td>" . $r['description'] . "</td><td>" . (strlen($r['default_value']) > 0 ? "default: " . $r['default_value'] : "") . (strlen($r['recommended_range']) > 0 ? "<br><div class='tip recommendedrange' data-toggle='tooltip' data-placement='left' title='Recommended range'><i class='fa fa-thumbs-o-up'></i> " . $r['recommended_range'] . "</div>" : "") . "</td></tr>";
    }
}
?>
				</table>
			</div>
      </div> <!-- end col-md-6 -->

	  <div class="qualities col-xs-12">
		  <?php 
$qtable = "";
if (sizeof($this->flow['qualities']) > 0) {
    echo '<h3>' . sizeof($this->flow['qualities']) . ' properties</h3>';
    foreach ($this->flow['qualities'] as $k => $v) {
        $qtable .= "<tr><td><a href='a/flow-qualities/" . cleanName($k) . "'>" . $k . "</a></td><td>";
        if (is_numeric($v)) {
            $qtable .= round($v, 2);
        } else {
            $qtable .= $v;
        }
        $qtable .= "</td></tr>";
    }
}
?>
    		 </div><div class="col-xs-12">
		 <?php 
if (strlen($qtable) > 1) {
    echo "<a data-toggle='collapse' href='#algoquals'><i class='fa fa-caret-right'></i> Show more</a><div id='algoquals' class='collapse'><div class='table-responsive'><table class='table table-striped'>" . $qtable . "</table></div></div>";
}
?>
示例#11
0
function compareTwoContacts($c1, $c2)
{
    global $thresholdUsernameSimilarity, $thresholdNameSimilarity;
    logMsg('DEBUG', "Comparing " . $c1['email'] . " with " . $c2['email']);
    // merge primary name with secondary names
    $c1Names = $c1['secondaryNames'];
    $c2Names = $c2['secondaryNames'];
    if ($c1['name']) {
        $c1Names[] = $c1['name'];
    }
    if ($c2['name']) {
        $c2Names[] = $c2['name'];
    }
    // if we have names
    if (count($c1Names) && count($c2Names)) {
        // clean names
        array_walk($c1Names, 'cleanName');
        array_walk($c2Names, 'cleanName');
        // check for exact items
        $commonNames = array_intersect($c1Names, $c2Names);
    }
    $c1Username = $c1['usernames'][0];
    cleanName($c1Username);
    $c2Username = $c2['usernames'][0];
    cleanName($c2Username);
    // check similarity
    if (!empty($commonNames)) {
        // full names match
        return 1;
    } elseif ($c1Username && $c2Username && ($usernameSimilarity = compareComplex($c1Username, $c2Username)) && $usernameSimilarity > $thresholdUsernameSimilarity) {
        // very high username similarity
        logMsg('DEBUG', "Username similarity between " . $c1Username . " and " . $c2Username . " is {$usernameSimilarity}");
        return 1;
    } elseif (count($c1Names) && count($c2Names)) {
        // check names similarity
        $nameSimilarity = 0;
        foreach ($c1Names as $c1Name) {
            if (!$c1Name) {
                continue;
            }
            $c1NamesSplit = explode(' ', $c1Name);
            $nameSimilarity = 0;
            foreach ($c2Names as $c2Name) {
                if (!$c2Name) {
                    continue;
                }
                $c2NamesSplit = explode(' ', $c2Name);
                $similarity = compareComplexMulti($c1NamesSplit, $c2NamesSplit);
                if ($similarity > $nameSimilarity) {
                    logMsg('DEBUG', "Name similarity between " . $c1Name . " and " . $c2Name . " is {$similarity}");
                    $nameSimilarity = $similarity;
                }
            }
        }
        unset($c1Names);
        unset($c2Names);
        unset($c1NamesSplit);
        unset($c2NamesSplit);
        return $nameSimilarity > $thresholdUsernameSimilarity ? 1 : 0;
    } else {
        unset($c1Names);
        unset($c2Names);
        return 0;
    }
}
require_once "constants.php";
$cache = "<?php";
//special handling for stores table (creating stores cache)
$selectStores = new MySqlSelect();
$selectStores->COLUMNS("*");
$selectStores->FROM("stores");
$selectStores->ADD_SORT("store_name", "desc");
$storesResult = db::MySqlSubmitQuery($selectStores->toString());
if ($storesResult) {
    $cache .= $newLine . "class db_cache_store{";
    while ($storesResultRow = mysql_fetch_array($storesResult, MYSQL_ASSOC)) {
        $cache .= $newLine . " public static \$" . "_" . cleanName($storesResultRow["store_name"]) . " = array(id => " . $storesResultRow["id"] . " , name => '" . $storesResultRow["store_name"] . "', default_tag_id => '" . $storesResultRow["default_tag_id"] . "');";
    }
    $cache .= $newLine . "}";
}
//special handling for tags table (creating stores cache)
$selectTags = new MySqlSelect();
$selectTags->COLUMNS("*");
$selectTags->FROM("tags");
$selectTags->ADD_SORT("tag_name", "desc");
$tagsResult = db::MySqlSubmitQuery($selectTags->toString());
if ($tagsResult) {
    $cache .= $newLine . "class db_cache_tag{";
    while ($tagsResultRow = mysql_fetch_array($tagsResult, MYSQL_ASSOC)) {
        $cache .= $newLine . " public static \$" . "_" . cleanName($tagsResultRow["tag_name"]) . " = array(id => " . $tagsResultRow["id"] . " , name => '" . $tagsResultRow["tag_name"] . "');";
    }
    $cache .= $newLine . "}";
}
$cache .= $newLine . "?>";
file_put_contents("cache.php", $cache);
echo 'complete.';
示例#13
0
<?php

include 'util.php';
$string = file_get_contents("../conf/conf.json");
$json_a = json_decode($string, true);
$host = $json_a['datasource']['host'];
$user = $json_a['datasource']['username'];
$pass = $json_a['datasource']['password'];
$db = $json_a['datasource']['database'];
$con = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}") or die("Could not connect to server\n");
$table = $_GET['table'];
$query = "SELECT * FROM " . $table;
$rs = pg_query($con, $query) or die("Cannot execute query: {$query}\n");
$players = array();
//key: player, value: array -> key: award, value: count
while ($row = pg_fetch_assoc($rs)) {
    $p = null;
    $playerName = cleanName($row['player']);
    if (!array_key_exists($playerName, $players)) {
        $players[$playerName] = array();
    }
    $players[$playerName][$row['award']] = $row['count'];
}
pg_close($con);
echo json_encode($players);
示例#14
0
<?php

include 'util.php';
$string = file_get_contents("../conf/conf.json");
$json_a = json_decode($string, true);
$host = $json_a['datasource']['host'];
$user = $json_a['datasource']['username'];
$pass = $json_a['datasource']['password'];
$db = $json_a['datasource']['database'];
$con = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}") or die("Could not connect to server\n");
$table = $_GET['table'];
$query = "SELECT * FROM " . $table;
$rs = pg_query($con, $query) or die("Cannot execute query: {$query}\n");
$players = array();
//key: player, value: array -> key: award, value: count
while ($row = pg_fetch_row($rs)) {
    $p = null;
    $playerName = cleanName($row[0]);
    $value = $row[1];
    $players[$playerName] = $value;
}
pg_close($con);
echo json_encode($players);
示例#15
0
        <ul>
            <li><a href="index.php">Home</a></li>
            <li><a href="ChoosePublicationToView.php">View Publications</a></li>
            <li><a href="importFile.php">Import Publication</a></li>
             <li><a href="search.php">New Search</a></li>
            <li>About</li>
            <li><a href="SearchResultsViewAll.php"> View All </a></li>
            <li><i>Viewer courtesy of BookBlock</i></li>
        </ul>
        <!--Banner and navigation bar !--> 
    </div>
        <?php 
if (!isset($_SESSION['SearchResults'])) {
    //sanitize form data and find personId number
    $cleanLastName = cleanName($_POST['lname']);
    $cleanFirstName = cleanName($_POST['fname']);
    $_SESSION['personId'] = findName($cleanLastName, $cleanFirstName, $pdo);
    if ($_POST['PubName'] == 'All') {
        $sql = $pdo->prepare("SELECT Page_PageId FROM PageInfo WHERE Person_PersonId=?");
        $sql->execute(array($_SESSION['personId']));
        $resultPageIds = $sql->fetchAll(PDO::FETCH_ASSOC);
        $_SESSION['row_count'] = $sql->rowCount();
    } else {
        //find publication id
        $sql = $pdo->prepare("SELECT PublicationId FROM Publication WHERE Name=?");
        $sql->execute(array($_POST['PubName']));
        $_SESSION['publicationId'] = $sql->fetchColumn();
        $sql = $pdo->prepare("SELECT Page_PageId FROM PageInfo WHERE Person_PersonId=? && Publication_PublicationId=?");
        $sql->execute(array($_SESSION['personId'], $_SESSION['publicationId']));
        $resultPageIds = $sql->fetchAll(PDO::FETCH_ASSOC);
        $_SESSION['row_count'] = $sql->rowCount();

	<?php 
$uNameErr = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $newUname = $_POST["new_u_name"];
    if (empty($_POST["new_u_name"])) {
        $uNameErr = "Please enter a user name";
    } else {
        if (!preg_match("/^[a-zA-Z0-9]*\$/", $newUname)) {
            $uNameErr = "Only letters and numbers allowed.";
        } else {
            if (nameExists($newUname)) {
                $uNameErr = "That username is taken, please choose another.";
            } else {
                $newUname = cleanName($_POST["new_u_name"]);
                insertHash($newUname);
            }
        }
    }
}
/** checks to see if this new username is already in the database */
function nameExists($newUname)
{
    global $servername, $username, $dbname, $password, $preid;
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } else {
        $sql = "SELECT * FROM users WHERE u_username = \"" . $newUname . "\";";