Esempio n. 1
0
function kMeans($data, $k, $normalize = false)
{
    $centroids = initialiseCentroids($data, $k, $normalize = false);
    $mapping = array();
    while (true) {
        $new_mapping = assignCentroids($data, $centroids);
        foreach ($new_mapping as $documentID => $centroidID) {
            if (!isset($mapping[$documentID]) || $centroidID != $mapping[$documentID]) {
                $mapping = $new_mapping;
                break;
            } else {
                return formatResults($mapping, $data, $centroids);
            }
        }
        $centroids = updateCentroids($mapping, $data, $k);
    }
}
        while (1) {
            $likes_centroides = posicionar_centroides($data, $centroids);
            /* Função para posicionar as centroides */
            $changed = false;
            /* Variável para verificar mudança do posicionamento das centroides */
            $current_category = $data[0][0];
            /* Qual a categoria corrente */
            foreach ($likes_centroides as $posicao => $centroide) {
                if (!isset($mapeamento[$posicao]) || $centroide != $mapeamento[$posicao]) {
                    $mapeamento = $likes_centroides;
                    $changed = true;
                    break;
                }
            }
            if (!$changed) {
                $result_kmeans[$i] = formatResults($mapeamento, $data);
                save_kmeans_centroids_positions($centroids, $current_category, $user);
                if ($i == $num_rows - 1) {
                    save_kmeans_data($result_kmeans, $user);
                    return $result_kmeans;
                }
                break;
            }
            $centroids = update_centroides($mapeamento, $data, $k);
        }
        $i++;
    }
}
function save_kmeans_centroids_positions($centroid_position, $current_category, $user)
{
    $insert = null;
Esempio n. 3
0
<?php

require "util/fileio.php";
$logfile = "log/runtimeperf_results.txt";
$benchmarkResults = formatResults($_POST["data"]);
saveLog($benchmarkResults, $logfile);
function formatResults($r)
{
    print_r($r);
    $r = stripcslashes($r);
    $r = json_decode($r);
    if (json_last_error() > 0) {
        die("invalid json");
    }
    return $r;
}
function formatNewLog($file)
{
    $headerline = "IP, TestID, StartTime, StopTime, RunTime, URL, UserAgent, PerceivedLoadTime, PageRenderTime, RoundTripTime, TCPConnectionTime, DNSLookupTime, CacheTime, RedirectTime";
    appendToFile($headerline, $file);
}
function saveLog($obj, $file)
{
    if (!file_exists($file)) {
        formatNewLog($file);
    }
    $obj->useragent = cleanCommas($obj->useragent);
    $newLine = $_SERVER["REMOTE_ADDR"] . "," . $obj->id . "," . $obj->startTime . "," . $obj->stopTime . "," . $obj->runtime . "," . $obj->url . "," . $obj->useragent . $obj->perceivedTime . "," . $obj->pageRenderTime . "," . $obj->roundTripTime . "," . $obj->tcpConnectionTime . "," . $obj->dnsLookupTime . "," . $obj->cacheTime . "," . $obj->redirectTime;
    appendToFile($newLine, $file);
}
function cleanCommas($data)
Esempio n. 4
0
function recordObject($irn)
{
    $mySession = IMuConnect();
    $terms = new IMuTerms();
    $cat = new IMuModule('ecatalogue', $mySession);
    $columns = array('irn', 'Creator=CreCreatorRef_tab.(Name=NamFullName)', 'Role=CreRole_tab', 'AccNo=TitAccessionNo', 'Medium=PhyMediumComments', 'Title=TitMainTitle', 'Year=CreDateCreated', 'Location=LocCurrentLocationRef.(LocLocationName,LocBarcode)', 'Children=<ecatalogue:AssParentObjectRef>.(irn, AccNo=TitAccessionNo, Title=TitMainTitle, Location=LocCurrentLocationRef.(LocLocationName, LocBarcode), TitBarcode)', 'MesType=MesMeasurementType_tab', 'H=MesTotalInchFrac_tab', 'W=MesTotWidthInchFrac_tab', 'D=MesTotDepthInchFrac_tab', 'Barcode=TitBarcode', 'image.resource{height:300,source:master}', 'NotesA=ConHandlingInstructions', 'NotesB=InsInstallationNotes');
    $terms->add('irn', trim($irn));
    $start = 0;
    $number = 100;
    try {
        $hits = $cat->findTerms($terms);
        $result = $cat->fetch('start', $start, $number, $columns);
        $result = formatResults($result);
        createRecords($result);
        return $result;
    } catch (Exception $e) {
        throwError($e);
    }
    return null;
}
Esempio n. 5
0
function query()
{
    $users = new usersMenus();
    $stringtofind = trim($_GET["backup_search"]);
    $stringtofind = str_replace("*", '', $stringtofind);
    $recipient_to_find = trim($_SESSION["backup_search_recipient"]);
    if ($recipient_to_find != null) {
        if (strpos($recipient_to_find, "*") == 0) {
            $recipient_to_find = $recipient_to_find . "*";
        }
        $recipient_to_find = str_replace("*", "%", $recipient_to_find);
        $recipient_to_find_fields = ",storage_recipients.recipient";
        $recipient_to_find = " AND storage_recipients.recipient LIKE '{$recipient_to_find}'";
    }
    $sender_to_find = trim($_SESSION["backup_search_sender"]);
    if ($sender_to_find != null) {
        if (strpos($sender_to_find, "*") == 0) {
            $sender_to_find = $sender_to_find . "*";
        }
        $sender_to_find = str_replace("*", "%", $sender_to_find);
        $sender_to_find = " AND storage.mailfrom LIKE '{$sender_to_find}'";
    }
    if (!$users->AsPostfixAdministrator) {
        $uid = $_SESSION["uid"];
        $ldap = new clladp();
        $user = new user($uid);
        $back = new backup_query($uid);
        $mymails = $back->sql_mymails;
        $sql = "SELECT storage.MessageID,storage.mailfrom{$recipient_to_find_fields},storage.zDate,storage.subject,storage.MessageBody,MATCH (storage.MessageBody) \n\t\t\tAGAINST (\"{$stringtofind}\") AS pertinence  \n\t\t\tFROM storage,storage_recipients WHERE storage.MessageID=storage_recipients.MessageID AND ({$mymails}){$recipient_to_find}{$sender_to_find} ORDER BY pertinence DESC LIMIT 0,90";
        if ($stringtofind == null) {
            $sql = "SELECT storage.MessageID,storage.mailfrom{$recipient_to_find_fields},storage.zDate,storage.subject,storage.MessageBody \n\t\t\t\tFROM storage,storage_recipients WHERE storage.MessageID=storage_recipients.MessageID AND ({$mymails}){$recipient_to_find}{$sender_to_find} ORDER BY zDate DESC LIMIT 0,90";
        }
    } else {
        $sql = "SELECT storage.MessageID,storage.mailfrom{$recipient_to_find_fields},storage.zDate,storage.subject,storage.MessageBody,MATCH (storage.MessageBody) \n\t\t\tAGAINST (\"{$stringtofind}\") AS pertinence  \n\t\t\tFROM storage,storage_recipients WHERE storage.MessageID=storage_recipients.MessageID{$recipient_to_find}{$sender_to_find} ORDER BY pertinence DESC LIMIT 0,90";
        if ($stringtofind == null) {
            $sql = "SELECT storage.MessageID,storage.mailfrom{$recipient_to_find_fields},storage.zDate,storage.subject,storage.MessageBody \n\t\t\t\tFROM storage,storage_recipients WHERE storage.MessageID=storage_recipients.MessageID{$recipient_to_find}{$sender_to_find} ORDER BY zDate DESC LIMIT 0,90";
        }
    }
    writelogs($sql, __FUNCTION__, __FILE__);
    $s = new mysql();
    $results = $s->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $html = $html . formatResults($ligne);
    }
    echo "{$html}";
    exit;
    $html = "<table style='width:100%'>\n<tr>\n\t<th>{date}</th>\n\t<th>{subject}</th>\n</tr>\n\n";
    while (list($num, $array) = each($arr)) {
        $html = $html . "\n\t<tr " . CellRollOver("ShowBackupMail('{$num}')") . " >\n\t<td nowrap valign='top' style='border-bottom:1px dotted #CCCCCC;padding:3px'>{$array[0]}</td>\n\t<td style='border-bottom:1px dotted #CCCCCC;padding:3px'>{$array[1]}</td>\n\t</tr>\n\t\n\t";
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html . "</table><br><br><code>{$sql}</code>");
}