Exemplo n.º 1
0
$rows = db_select_all(TBL_PREFIX . TBL_RECORDS, "*", "domain_id='" . $_POST['domain_id'] . "' ORDER BY id DESC");
if (count($rows) > 0) {
    $users = array();
    $pages = array();
    $dict_user = array();
    $dict_page = array();
    foreach ($rows as $row) {
        // extract mouse features
        $mf = new MouseFeat(array('x' => $row['coords_x'], 'y' => $row['coords_y'], 'c' => $row['clicks'], 'f' => $row['fps'], 'w' => $row['vp_width'], 'h' => $row['vp_height']));
        // and use (some of) those features to cluster user behaviors (more features lead to slower computation!)
        $users[] = array($mf->time, $mf->numClicks, $mf->activity, $mf->distance['x'], $mf->scrollReach['y']);
        // those behaviors may belong to different pages
        $cache = db_select(TBL_PREFIX . TBL_CACHE, "url", "id = '" . $row['cache_id'] . "'");
        $url = $cache['url'];
        // check whether URLs should be merged (just remove query string)
        if (db_option(TBL_PREFIX . TBL_CMS, "mergeCacheUrl")) {
            $urlparts = explode("?", $url);
            $url = $urlparts[0];
        }
        if (isset($pages[$url])) {
            $pages[$url] += 1;
        } else {
            $pages[$url] = 1;
        }
        $dict_user[] = $row['id'];
        $dict_page[] = $url;
    }
    $n = count($pages);
    $k = ceil(sqrt($n / 2));
    $km = new KMeans(whiten($users), $k);
    //$km->initRandom();
Exemplo n.º 2
0
Arquivo: sql.php Projeto: gepuro/smt2
     //
     $fps[] = (int) $log['fps'];
     $hovered .= $log['hovered'];
     $clicked .= $log['clicked'];
     $timestamp = mask_client($log['client_id']) . '\\n' . date("h:i A", strtotime($log['sess_date']));
     $hn = new Hypernote($_GET['pid'], $_SESSION['login']);
     $hypernotes = $hn->getData(false);
     // build JavaScript object
     $JSON[] = '{' . '"id": ' . $log['id'] . ', ' . '"xcoords": [' . $log['coords_x'] . '], ' . '"ycoords": [' . $log['coords_y'] . '], ' . '"clicks":  [' . $log['clicks'] . '], ' . '"timestamp": "' . $timestamp . '", ' . '"hypernotes": ' . json_encode($hypernotes) . ', ' . '"wprev": ' . $vpw . ', ' . '"hprev": ' . $vph . ', ' . '"time": ' . $log['sess_time'] . '' . '}';
 }
 // set a common frame rate for all tracks
 $fps = ceil(array_avg($fps));
 $viewportWidth = ceil(array_avg($viewportWidth));
 $viewportHeight = ceil(array_avg($viewportHeight));
 // compute the average user path, if need be ---------------------------------
 if (db_option(TBL_PREFIX . TBL_CMS, "displayAvgTrack")) {
     // preprocess: pad all mouse vectors
     $maxWeight = max($weights);
     foreach ($weights as $i => $w) {
         $items = count($coordsX[$i]);
         $diff = $maxWeight - $items;
         if ($diff > 0) {
             $coordsX[$i] = array_pad($coordsX[$i], $items + $diff, 0);
             $coordsY[$i] = array_pad($coordsY[$i], $items + $diff, 0);
             $clicks[$i] = array_pad($clicks[$i], $items + $diff, 0);
         }
     }
     $users = count($logs);
     // chek logs count to access coordinates index
     foreach ($logs as $i => $log) {
         // compound single path
Exemplo n.º 3
0
// server settings are required - relative path to smt2 root dir
require '../../../config.php';
// protect extension from being browsed by anyone
require SYS_DIR . 'logincheck.php';
// now you have access to all CMS API
// use ajax settings
require './includes/settings.php';
// insert custom CSS and JS files
$headOpts = array('<link rel="stylesheet" type="text/css" href="styles/table.css" />', '<link rel="stylesheet" type="text/css" href="styles/flags.css" />', '<link rel="stylesheet" type="text/css" href="styles/ui-lightness/custom.css" />');
add_head($headOpts);
include INC_DIR . 'header.php';
// display a warning message for javascript-disabled browsers
echo check_noscript();
// check defaults from DB or current sesion
$show = isset($_SESSION['limit']) && $_SESSION['limit'] > 0 ? $_SESSION['limit'] : db_option(TBL_PREFIX . TBL_CMS, "recordsPerTable");
// sanitize
if (!$show) {
    $show = $defaultNumRecords;
}
?>

    <p><a href="./howto/">Some guides are available</a> to help you with these logs.</p>
    
    <div class="center">
      <!-- Order by date (descending) and client ID -->
      <h1>User logs</h1>
      
      <div id="records">
        <?php 
check_notified_request("records");
Exemplo n.º 4
0
$URL = $_POST['url'];
// check proxy requests
$pattern = "proxy/index.php?url=";
if (strpos($URL, $pattern)) {
    list($remove, $URL) = explode($pattern, $URL);
    $URL = base64_decode($URL);
}
// get remote webpage
$request = get_remote_webpage($URL, array(CURLOPT_COOKIE => $_POST['cookies']));
$webpage = utf8_encode($request['content']);
// check request status
if ($request['errnum'] != CURLE_OK || $request['http_code'] != 200) {
    $webpage = error_webpage('<h1>Could not fetch page</h1><pre>' . print_r($request, true) . '</pre>');
    $parse = true;
} else {
    $cachedays = db_option(TBL_PREFIX . TBL_CMS, "cacheDays");
    // is cache enabled?
    if ($cachedays > 0) {
        // get the most recent version saved of this page
        $cachelog = db_select(TBL_PREFIX . TBL_CACHE, "id,UNIX_TIMESTAMP(saved) as savetime", "url='" . $URL . "' ORDER BY id DESC");
        // check if url exists on cache, and if it should be stored (again) on cache
        if ($cachelog && time() - $cachelog['savetime'] < $cachedays * 86400) {
            // get HTML log id
            $cache_id = $cachelog['id'];
            $parse = false;
        } else {
            // cache days expired
            $parse = true;
        }
    } else {
        // cache is disabled
Exemplo n.º 5
0
require REQUIRED . '/functions.db.php';
// ---------------------------------------------------------- smt2 constants ---
require REQUIRED . '/define.php';
require REQUIRED . '/messages.php';
// --------------------------------------------------------------- utilities ---
require REQUIRED . '/class.domutil.php';
require REQUIRED . '/class.browser.php';
require REQUIRED . '/class.kmeans.php';
require REQUIRED . '/class.mousefeat.php';
require REQUIRED . '/class.hypernote.php';
// ------------------------------------------------------------------ others ---
require REQUIRED . '/functions.array.php';
require REQUIRED . '/functions.url.php';
//require_once realpath(REQUIRED.'/../../').'/core/functions.php';
require_once BASE_PATH . '/core/functions.php';
if (@db_option(TBL_PREFIX . TBL_CMS, "enableDebugging")) {
    error_reporting(E_ALL | E_STRICT);
} else {
    error_reporting(E_ERROR);
}
/** 
 * Additional head tags. Enable inserting custom tags on page head.
 * @global array $_headAdded
 */
$_headAdded = array();
/** 
 * Checks if server is ready to work with smt2 by comparing the server's $type version.
 * At least are required both PHP 5 and MySQL 5.
 * @param   string    $type       "php" or "mysql", by now
 * @param   string    $minReqVer  minimun system version (default: 5.0.0) 
 * @return  boolean               TRUE on sucess, or FALSE on failure 
Exemplo n.º 6
0
                // skip visualization items from log data
                $logs = db_select_all(TBL_PREFIX . TBL_RECORDS, "*", "ip = '" . base64_decode($_GET['lid']) . "'");
                if (db_option(TBL_PREFIX . TBL_CMS, "displayGoogleMap")) {
                    $IP = $_GET['lid'];
                    include './includes/rawlog-location.php';
                }
            }
        }
    }
}
// now compute grouped metrics
if (isset($_GET['cid']) || isset($_GET['pid']) || isset($_GET['lid'])) {
    if (!$logs) {
        die("Error retrieving logs.");
    }
    $sampleSize = db_option(TBL_PREFIX . TBL_CMS, "maxSampleSize");
    if ($sampleSize > 0) {
        $keys = array_rand($logs, $sampleSize);
    }
    // group metrics
    $hovered = "";
    $clicked = "";
    foreach ($logs as $i => $log) {
        if (isset($_GET['pid']) && (isset($keys) && !in_array($i, $keys))) {
            continue;
        }
        //$time[] = $log['sess_time'];
        $mouseTracks[] = array('x' => $log['coords_x'], 'y' => $log['coords_y'], 'c' => $log['clicks'], 'f' => $log['fps'], 'w' => $log['vp_width'], 'h' => $log['vp_height']);
        $hovered .= $log['hovered'];
        $clicked .= $log['clicked'];
    }
Exemplo n.º 7
0
    $page = $request ? $request['content'] : error_webpage();
    // hide warnings when parsing non valid (X)HTML pages
    @$doc->loadHTML($page);
    remove_smt_scripts($doc);
} else {
    if (!is_file($file)) {
        // page not in cache and not fetched
        @$doc->loadHTML(error_webpage($errpage));
        remove_smt_scripts($doc);
    } else {
        // page in cache (smt scripts were already removed)
        @$doc->loadHTMLFile(utf8_decode($file));
    }
}
// include user data
include './includes/user.php';
// hilite hovered/clicked elements
if (db_option(TBL_PREFIX . TBL_CMS, "displayWidgetInfo")) {
    include './includes/widget.php';
}
// include drawing API
$api = "swf";
//$_GET['api'];
$apiFile = './includes/api-' . $api . '.php';
if (!file_exists($apiFile)) {
    die("API file not found!");
}
include $apiFile;
include './includes/api-parse.php';
// finally render page
echo $doc->saveHTML();
Exemplo n.º 8
0
    if ($o['type'] == CMS_TYPE) {
        // check 6 digits for colors
        while (strlen($val) < 6) {
            $val .= "0";
        }
        // finally add the hex flag
        $val = '"#' . $val . '"';
    }
    // display JS object properties
    $customprop[] = "\t" . $prop . ': ' . $val;
}
$cdata_options = '
//<![CDATA[
smt2.replay({
  ' . implode("," . PHP_EOL, $customprop) . '
});
';
if (db_option(TBL_PREFIX . TBL_CMS, "refreshOnResize")) {
    $cdata_options .= '
    (function(){
      smt2fn.addEvent(window, "resize", smt2fn.reloadPage);
    })();
  ';
}
$cdata_options .= '
//]]>
';
// create user data script
$js_options = $doc->createInlineScript($cdata_options);
// create replay script (and insert it before $js_options)
$js_replay = $doc->createExternalScript(SMT_REPLAY);