Пример #1
0
function runBenchmark($n = 10, $options = array())
{
    // Current settings used by Helioviewer.org
    $defaults = array("inter_format" => "PNG", "output_format" => "PNG", "type" => "Imagick::IMGTYPE_GRAYSCALE", "interlace" => "IMagick::INTERLACE_PLANE", "compression" => "IMagick::COMPRESSION_JPEG", "input_quality" => null, "output_quality" => 20, "depth" => 8, "imgstrings" => false, "base64" => false, "use_gd" => true);
    // Replace default options
    $options = array_replace($defaults, $options);
    // Import image builder
    if ($options['imgstrings']) {
        require_once "src/ImageBuilderNew.php";
    } else {
        require_once "src/ImageBuilderOld.php";
    }
    set_time_limit(3000);
    // Run test n times using specified options
    $times = array();
    for ($i = 0; $i < $n; $i++) {
        $start = microtime(true);
        buildImage($options);
        $end = microtime(true);
        $time = $end - $start;
        array_push($times, $time);
    }
    // Print results
    printResults($times, $options);
}
Пример #2
0
function runMainDemo(&$analytics)
{
    try {
        // Step 2. Get the user's first view (profile) ID.
        $profileId = GOOGLE_ANALYTICS_PROFILE_ID;
        if (isset($profileId)) {
            // Step 3. Query the Core Reporting API.
            $results = getResults($analytics, $profileId);
            // Step 4. Output the results.
            printResults($results);
        }
    } catch (apiServiceException $e) {
        // Error from the API.
        print 'There was an API error : ' . $e->getCode() . ' : ' . $e->getMessage();
    } catch (Exception $e) {
        print 'There was a general error : ' . $e->getMessage();
    }
}
Пример #3
0
<?php

session_start();
error_reporting(0);
include "includes/header.inc";
?>
<div id="content">
  <div id="errorFlash" class="error" style="display:none"></div>
  <?php 
printForm();
$userGuess = filter_input(INPUT_POST, "userGuess");
if (isset($userGuess)) {
    $compGuess = CompGuess();
    $winner = updateScores($userGuess, $compGuess);
    printResults($userGuess, $compGuess, $winner);
}
?>
</div>
<?php 
include "includes/footer.inc";
?>

<?php 
// fuction defs
function compGuess()
{
    return rand(0, 2);
}
function updateScores($userGuess, $compGuess)
{
    $beats = array(1, 2, 0);
Пример #4
0
     $searchedvalue = $_POST['searchedvalue'];
     executePlainSQL("delete from {$tablename}" . " where {$deletesearchby} = '{$searchedvalue}'");
     OCICommit($db_conn);
     // save selection for next load
     setcookie("deletesearchby", $deletesearchby);
 }
 if ($_POST && $success) {
     //POST-REDIRECT-GET -- See http://en.wikipedia.org/wiki/Post/Redirect/Get
     header("location: admin.php");
     // default will check if there is any table already selected and output that
 } else {
     if (strcmp($_COOKIE['tabchoice'], "") !== 0 && strcmp($_COOKIE['tabchoice'], "default") !== 0) {
         $tabchoice = $_COOKIE['tabchoice'];
         $cols = executePlainSQL("select column_name from user_tab_columns where table_name = '{$tabchoice}'");
         $data = executePlainSQL("select * from " . $tabchoice);
         printResults($tabchoice, $cols, $data);
         // retrieve past delete/update selection from cookie for this load
         $updatesearchby = $_COOKIE['updatesearchby'];
         $deletesearchby = $_COOKIE['deletesearchby'];
         // delete them as only needed for one load
         setcookie("updatesearchby", "", time() - 3600);
         setcookie("deletesearchby", "", time() - 3600);
         // set the drop down lists according to the cookie (last delete/update selections)
         echo "<script>document.getElementById('tabchoice').value='{$tabchoice}'</script>";
         if (strcmp($_COOKIE['updatesearchby'], "") !== 0) {
             echo "<script>document.getElementById('updatesearchby').value='{$updatesearchby}'</script>";
         }
         if (strcmp($_COOKIE['deletesearchby'], "") !== 0) {
             echo "<script>document.getElementById('deletesearchby').value='{$deletesearchby}'</script>";
         }
     }
Пример #5
0
$tests = 50;
$print = true;
$verbose = false;
$filename = __DIR__ . '/data/minhash/results.' . date('Y-m-d_h-i-s') . '.csv';
file_put_contents($filename, '');
for ($i = $testMin; $i <= $testMax; $i += $block) {
    $block = pow(10, max(0, floor(log10($i))));
    $test = new Test($i);
    $test->test($tests);
    if ($print) {
        if ($verbose) {
            testHeader('Tested: ' . $i);
            printResults($test->results());
        }
        testHeader('Average: ' . $i);
        printResults(array($test->averages()));
    }
    fileResults($filename, $test->results());
    echo "Tested {$i}\r";
}
echo PHP_EOL;
class Test
{
    private $i;
    private $average = array(0, 0, 0);
    private $results = array();
    public function __construct($i)
    {
        $this->i = $i;
    }
    private function random()
Пример #6
0
        }
    }
}
if (isset($_POST["calc"]) and $_POST["calc"] != "") {
    $flag2 = True;
    $calc = $_POST['calc'];
    foreach ($calc as $value) {
        if ($value == "GSE") {
            $gse = True;
        } elseif ($value == "energy") {
            $elev = True;
        }
    }
}
if ($flag1 && $flag2) {
    printResults($_POST["atom"], $box, $sho, $pos, $gse, $elev);
}
printBottom();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~BEGIN FUNCTIONS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Need to add javascript in printBottom() to check for correct submission?
function printForm()
{
    $script = $_SERVER['PHP_SELF'];
    //Maybe put a box around the form so it looks cool?
    print <<<FORM
  <div id="content">
  <div id="c2">
  <p><b> Select your Parameters </b></p>
    <form method="POST" action={$script} id="formContent">
    <p> Atom: <select name="atom">
      <option selected="selected"> H </option>
Пример #7
0
 public function google_login()
 {
     require_once APPPATH . 'libraries/google-api-php-client/src/Google/autoload.php';
     //$this->load->model('users_model');
     //$redirect = isEmpty($this->input->get('referuri'))?'':$this->input->get('referuri');
     $data = array();
     //echo 'test';
     // Start a session to persist credentials.
     //session_start();
     //echo BASEPATH;
     //var_dump(is_file(APPPATH.'libraries/google-api-php-client/client_secrets.json'));
     //exit('test');
     // Create the client object and set the authorization configuration
     // from the client_secrets.json you downloaded from the Developers Console.
     $client = new Google_Client();
     $client->setAuthConfigFile(APPPATH . 'libraries/google-api-php-client/client_secrets.json');
     //$client->setRedirectUri(base_url('login/google_callback'));
     $client->setScopes('email');
     $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
     // If the user has already authorized this app then get an access token
     // else redirect to ask the user to authorize access to Google Analytics.
     if ($this->session->userdata('access_token') != '') {
         // Set the access token on the client.
         $client->setAccessToken($this->session->userdata('access_token'));
         // Create an authorized analytics service object.
         $analytics = new Google_Service_Analytics($client);
         // Get the first view (profile) id for the authorized user.
         $profile = getFirstProfileId($analytics);
         // Get the results from the Core Reporting API and print the results.
         printResults(getResults($analytics, $profile));
     } else {
         $redirect_uri = base_url('login/google_callback');
         //header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
         redirect(filter_var($redirect_uri, FILTER_SANITIZE_URL));
     }
 }
Пример #8
0
        $wikitext = get_wiki_text($langParameters, $wikiSource, $word);
        $hyperArray = $HyperParse->get_hyper($wikitext, $count);
        printResults($hyperArray);
        break;
        /***********************************************************************************/
        // Include genderparse class and create new object with 3 variables. (Gender)
        /***********************************************************************************/
    /***********************************************************************************/
    // Include genderparse class and create new object with 3 variables. (Gender)
    /***********************************************************************************/
    case "gender":
        include 'classes/class.genderparse.php';
        $GenderParse = new GenderParse($langParameters);
        $wikitext = get_wiki_text($langParameters, $wikiSource, $word);
        $genderArray = $GenderParse->get_gender($wikitext, $count);
        printResults($genderArray);
        break;
        /***********************************************************************************/
    /***********************************************************************************/
    default:
        echo "You must specify a valid query type ('pos', 'def', 'syn', 'hyper', or 'gender').";
        break;
}
/***********************************************************************************/
// Include wikiextract class and create new object with 2 variables. Returns the
// contents of the wiktionary entry for a given word.
/***********************************************************************************/
function get_wiki_text($langParameters, $wikiSource, $word)
{
    include 'classes/class.wikiextract.php';
    $WikiExtract = new WikiExtract($langParameters, $wikiSource);
Пример #9
0
function getlogs($pkg_name)
{
    global $total_exact_hits;
    global $total_nonobject_hits;
    global $total_object_hits;
    global $total_exact;
    global $total_nonobject;
    global $total_object;
    $sql = 'SELECT * FROM fields WHERE pkgname ="' . mysql_real_escape_string($pkg_name) . '" AND type=classname;';
    //echo $sql;
    $result = @mysql_query($sql);
    if (!$result) {
        echo "<p> no records found </p>\n";
        exit;
    }
    echo "<p><a href=\"#\" onclick=\"display_report('", $pkg_name, "')\">", Hide, "</a></p>\n";
    echo "<div id=\"", $pkg_name, "\" class=\"unhidden\">\n";
    echo "<a href=\"?log=", $pkg_name, ".ds-finder.log\">", $pkg_name, " summary log</a><br />\n";
    echo "<a href=\"?log=", $pkg_name, ".ds-finder.log-full\">", $pkg_name, " summary log-full</a><br />\n";
    //  echo "<a href=\"logs/$pkg_name.ds-finder.log\">",$pkg_name, " summary log</a><br />\n";
    //  echo "<a href=\"logs/$pkg_name.ds-finder.log-full\">",$pkg_name, " full logged output</a><br />\n";
    echo "<p>EXACT FIELD MATCHES:</p>\n";
    printResults($result, $total_exact, $total_exact_hits);
    $sql = 'SELECT * FROM fields WHERE pkgname="' . mysql_real_escape_string($pkg_name) . '" AND type!=classname AND type!="java.lang.Object";';
    $result = @mysql_query($sql);
    if (!$result) {
        echo "<p> no records found </p>\n";
        exit;
    }
    echo "<p>NON-OBJECT FIELDS:</p>\n";
    printResults($result, $total_nonobject, $total_nonobject_hits);
    $sql = 'SELECT * FROM fields WHERE pkgname="' . mysql_real_escape_string($pkg_name) . '" AND type="java.lang.Object";';
    $result = @mysql_query($sql);
    if (!$result) {
        echo "<p> no records found </p>\n";
        exit;
    }
    echo "<p>OBJECT FIELDS:</p>\n";
    printResults($result, $total_object, $total_object_hits);
    echo "<hr /><hr />\n";
    echo "</div>\n";
}
Пример #10
0
		
<?php 
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
$action = $HTTP_POST_VARS['action'];
if ($action == "generate") {
    // Get Form Data
    $name = htmlentities($HTTP_POST_VARS['frmName'], ENT_QUOTES);
    $expiryDay = $HTTP_POST_VARS['expiryDay'];
    $expiryMonth = $HTTP_POST_VARS['expiryMonth'];
    $expiryYear = $HTTP_POST_VARS['expiryYear'];
    $expiry = mktime(23, 59, 59, $expiryMonth, $expiryDay, $expiryYear);
    // Include The Code Generator API & Run It
    include 'generate_api.php';
    $licCode = phpunlock_generate($name, $expiry, "4fk494k3asdfasdf920k334", "dierk4dasdfasdfidk3i232", "94kdkeifasdfk2i2k23d", "dikeowl3adfasd92kdowi");
    // Print Out The Results
    printResults();
} else {
    printForm();
}
function printForm()
{
    global $PHP_SELF;
    echo "<html>\n";
    echo "<head>\n";
    echo "<title>Генератор</title>\n";
    echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">\n";
    echo "</head>\n";
    echo "\n";
    echo "<body>\n";
    echo "<font class=\"content\">Каждая игра запускается и работает используя свой, неповторимый код.\n Таким образом никто не в состоянии повлиять на игровой процесс.<br>Как работает: При запуске игры данные передаются на генератор случайного кода. \nГенерируется код и запускается игровой процесс. При выходе из игры код скидывается. При запуске новой игры генерируется новый случайный код. \nКак примерно эта система работает вы можете проверить в форме ниже. Введите любое значение в поле. Это может быть любой набор символов. \nНажмите кнопку Сгенерировать код. Удачной Вам игры.</font>\n";
    echo "<p>&nbsp;</p>\n";
Пример #11
0
  <?php 
//            LOGIN PAGE
//check the username/password have been set
if (isset($_POST["user"]) and isset($_POST["pswd"])) {
    $user = trim($_POST["user"]);
    $pswd = trim($_POST["pswd"]);
    //if is set, check if is valid
    if (validate($user, $pswd)) {
        //if is valid, check if is in results page
        if (inResults($user)) {
            //if in results.txt, print out his results
            printResults($user);
            // header('Location: ./newshome.html');    // CHANGE THIS LINK
        } else {
            header('Location: ./assignment12.php');
        }
    } else {
        login_invalid();
    }
} else {
    print <<<PAGE
  <html>
  <head>
  <title> Login </title>
  </head>
  <body>
  <h3> Login </h3>
  <form action = "./login.php" method = "POST">
  <table border = "0">
    <tr>
      <td> Enter Username: </td><td><input type = "text" name = "user" /></td>
Пример #12
0
                                            </div>
                                    </div>';
            }
        }
        if ($no_of_results == 0) {
            echo '<div class="row alert alert-danger adj-alert" role="alert">Oops!Sorry, no results found.</div>';
        }
    }
    if ($conn = mysqli_connect(HOST, DB_USER, "", 'bike_data')) {
        $result = mysqli_query($conn, "select * from buy_bikes") or die(mysqli_error());
        $no_of_rows = mysqli_num_rows($result) or die(mysqli_error($conn));
        while ($row = mysqli_fetch_assoc($result)) {
            $bike_arr[] = $row;
        }
    }
    for ($i = 0; $i < $no_of_rows; $i++) {
        if ($bike_arr[$i]['PRICE'] > 70000) {
            $rent[$i] = 1500;
            // echo '<p class="price">Price: Rs.'.$rent[$i].'</p>';
        } else {
            $rent[$i] = 1000;
            // echo '<p class="price">Price: Rs.'.$rent[$i].'</p>';
        }
    }
    if ($price_limit == 0) {
        printResults($conn, $bike_arr, $rent, $no_of_rows, $brands);
    } else {
        printResults($conn, $bike_arr, $rent, $no_of_rows, $brands, $price_limit);
    }
}
// echo $filter_count;
Пример #13
0
function drawEntries($fid, $cols, $searches = "", $frid = "", $scope, $standalone = "", $currentURL, $gperm_handler, $uid, $mid, $groups, $settings, $member_handler, $screen, $data, $wq, $regeneratePageNumbers, $hiddenQuickSearches, $cResults)
{
    // , $loadview="") { // -- loadview removed from this function sept 24 2005
    // determine if the query reached a limit in the number of entries to return
    $LOE_limit = 0;
    if (!is_array($data)) {
        $LOE_limit = is_numeric($data) ? $data : 0;
        $data = array();
    }
    global $xoopsDB;
    $useScrollBox = true;
    $useHeadings = true;
    $repeatHeaders = 5;
    $columnWidth = 0;
    $textWidth = 35;
    $useCheckboxes = 0;
    $useViewEntryLinks = 1;
    $useSearch = 1;
    $deColumns = array();
    $useSearchCalcMsgs = 1;
    $listTemplate = false;
    $inlineButtons = array();
    $hiddenColumns = array();
    $formulize_LOEPageSize = 10;
    if ($screen) {
        $useScrollBox = $screen->getVar('usescrollbox');
        $useHeadings = $screen->getVar('useheadings');
        $repeatHeaders = $screen->getVar('repeatheaders');
        $columnWidth = $screen->getVar('columnwidth');
        $textWidth = $screen->getVar('textwidth');
        if ($textWidth == 0) {
            $textWidth = 10000;
        }
        $useCheckboxes = $screen->getVar('usecheckboxes');
        $useViewEntryLinks = $screen->getVar('useviewentrylinks');
        $useSearch = $screen->getVar('usesearch');
        $hiddenColumns = $screen->getVar('hiddencolumns');
        $deColumns = $screen->getVar('decolumns');
        $deDisplay = $screen->getVar('dedisplay');
        $useSearchCalcMsgs = $screen->getVar('usesearchcalcmsgs');
        $listTemplate = $screen->getTemplate("listtemplate");
        foreach ($screen->getVar('customactions') as $caid => $thisCustomAction) {
            if ($thisCustomAction['appearinline'] == 1) {
                list($caCode) = processCustomButton($caid, $thisCustomAction);
                if ($caCode) {
                    $inlineButtons[$caid] = $thisCustomAction;
                }
            }
        }
        $formulize_LOEPageSize = $screen->getVar('entriesperpage');
    }
    $filename = "";
    // $settings['xport'] no longer set by a page load, except if called as part of the import process to create a template for updating
    if (!$settings['xport']) {
        $settings['xport'] = $settings['hlist'] ? "calcs" : "comma";
        $xportDivText1 = "<div id=exportlink style=\"display: none;\">";
        // export button turns this link on and off now
        $xportDivText2 = "</div>";
    } else {
        $xportDivText1 = "";
        $xportDivText2 = "";
    }
    if (@$_POST['advcalc_acid']) {
        if ($_POST['acid'] > 0) {
            $result = formulize_runAdvancedCalculation(intval($_POST['acid']));
            // result will be an array with two or three keys: 'text' and 'output', and possibly 'groupingMap'.  Text is for display on screen "raw" and Output is a variable that can be used by a dev.  The output variable will be an array if groupings are in effect.  The keys of the array will be the various grouping values in effect.  The groupingMap will be present if there's a set of groupings in effect.  It is an array that contains all the grouping choices, their text equivalents and their data values (which are the keys in the output array) -- groupingMap is still to be developed/added to the mix....will be necessary when we are integrating with Drupal or other API uses.
            print "<br/>" . $result['text'] . "<br/><br/>";
        }
    }
    // export of Data is moved out to a popup
    // Calculations still handled in the old way for now
    if ($settings['xport'] == "calcs") {
        $filename = prepExport($headers, $cols, $data, $settings['xport'], $settings['xport_cust'], $settings['title'], false, $fid, $groups);
        $linktext = $_POST['xport'] == "update" ? _formulize_DE_CLICKSAVE_TEMPLATE : _formulize_DE_CLICKSAVE;
        print "{$xportDivText1}<center><p><a href='{$filename}' target=\"_blank\">{$linktext}</a></p></center>";
        print "<br>{$xportDivText2}";
    }
    $scrollBoxWasSet = false;
    if ($useScrollBox and count($data) > 0) {
        print "<div class=scrollbox id=resbox>\n";
        $scrollBoxWasSet = true;
    }
    // perform calculations...
    // calc_cols is the columns requested (separated by / -- ele_id for each, also metadata is indicated with uid, proxyid, creation_date, mod_date)
    // calc_calcs is the calcs for each column, columns separated by / and calcs for a column separated by ,. possible calcs are sum, avg, min, max, count, per
    // calc_blanks is the blank setting for each calculation, setup the same way as the calcs, possible settings are all,  noblanks, onlyblanks
    // calc_grouping is the grouping option.  same format as calcs.  possible values are ele_ids or the uid, proxyid, creation_date and mod_date metadata terms
    // 1. extract data from four settings into arrays
    // 2. loop through the array and perform all the requested calculations
    if ($settings['calc_cols'] and !$settings['hcalc']) {
        //		print "<p><input type=button style=\"width: 140px;\" name=cancelcalcs1 value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input></p>\n";
        //		print "<div";
        //		if($totalcalcs>4) { print " class=scrollbox"; }
        //		print " id=calculations>
        $calc_cols = $settings['calc_cols'];
        $calc_calcs = $settings['calc_calcs'];
        $calc_blanks = $settings['calc_blanks'];
        $calc_grouping = $settings['calc_grouping'];
        print "<table class=outer>";
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        print "</table>";
        print "<table class=outer><tr><th colspan=2>" . _formulize_DE_CALCHEAD . "</th></tr>\n";
        if (!$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            print "<tr><td class=head colspan=2><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols=" . urlencode($calc_cols) . "&calc_calcs=" . urlencode($calc_calcs) . "&calc_blanks=" . urlencode($calc_blanks) . "&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;" . "<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp" . "<input type=button style=\"width: 140px;\" name=showlist value='" . _formulize_DE_SHOWLIST . "' onclick=\"javascript:showList();\"></input></td></tr>";
        }
        $exportFilename = $settings['xport'] == "calcs" ? $filename : "";
        //formulize_benchmark("before printing results");
        // 0 is the masterresults, 1 is the blanksettings, 2 is grouping settings -- exportFilename is the name of the file that we need to create and into which we need to dump a copy of the calcs
        printResults($cResults[0], $cResults[1], $cResults[2], $cResults[3], $cResults[4], $exportFilename, $settings['title']);
        //formulize_benchmark("after printing results");
        print "</table>\n";
    }
    // MASTER HIDELIST CONDITIONAL...
    if (!$settings['hlist'] and !$listTemplate) {
        print "<div class=\"list-of-entries-container\"><table class=\"outer\">";
        $count_colspan = count($cols) + 1;
        if ($useViewEntryLinks or $useCheckboxes != 2) {
            $count_colspan_calcs = $count_colspan;
        } else {
            $count_colspan_calcs = $count_colspan - 1;
        }
        $count_colspan_calcs = $count_colspan_calcs + count($inlineButtons);
        // add to the column count for each inline custom button
        $count_colspan_calcs++;
        // add one more for the hidden floating column
        if (!$screen) {
            print "<tr><th colspan={$count_colspan_calcs}>" . _formulize_DE_DATAHEADING . "</th></tr>\n";
        }
        if ($settings['calc_cols'] and !$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            $calc_cols = $settings['calc_cols'];
            $calc_calcs = $settings['calc_calcs'];
            $calc_blanks = $settings['calc_blanks'];
            $calc_grouping = $settings['calc_grouping'];
            print "<tr><td class=head colspan={$count_colspan_calcs}><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols={$calc_cols}&calc_calcs={$calc_calcs}&calc_blanks={$calc_blanks}&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=hidelist value='" . _formulize_DE_HIDELIST . "' onclick=\"javascript:hideList();\"></input></td></tr>";
        }
        // draw advanced search notification
        if ($settings['as_0'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 2)) {
            $writable_q = writableQuery($wq);
            $minus1colspan = $count_colspan - 1 + count($inlineButtons);
            if (!$asearch_parse_error) {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    // only include this column if necessary
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head>" . _formulize_DE_ADVSEARCH . ": {$writable_q}";
            } else {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head><span style=\"font-weight: normal;\">" . _formulize_DE_ADVSEARCH_ERROR . "</span>";
            }
            if (!$settings['lockcontrols']) {
                // AND !$loadview) { // -- loadview removed from this function sept 24 2005
                print "<br><input type=button style=\"width: 140px;\" name=advsearch value='" . _formulize_DE_MOD_ADVSEARCH . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/advsearch.php?fid={$fid}&frid={$frid}";
                foreach ($settings as $k => $v) {
                    if (substr($k, 0, 3) == "as_") {
                        $v = str_replace("'", "&#39;", $v);
                        $v = stripslashes($v);
                        print "&{$k}=" . urlencode($v);
                    }
                }
                print "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelasearch value='" . _formulize_DE_CANCELASEARCH . "' onclick=\"javascript:killSearch();\"></input>";
            }
            print "</td></tr>\n";
        }
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        if (count($data) == 0) {
            // kill an empty dataset so there's no rows drawn
            unset($data);
        } else {
            // get form handles in use
            $mainFormHandle = key($data[key($data)]);
        }
        $headcounter = 0;
        $blankentries = 0;
        $GLOBALS['formulize_displayElement_LOE_Used'] = false;
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        // adjust formulize_LOEPageSize if the actual count of entries is less than the page size
        $formulize_LOEPageSize = $GLOBALS['formulize_countMasterResultsForPageNumbers'] < $formulize_LOEPageSize ? $GLOBALS['formulize_countMasterResultsForPageNumbers'] : $formulize_LOEPageSize;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (isset($data)) {
            foreach ($data as $id => $entry) {
                formulize_benchmark("starting to draw one row of results");
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    if ($headcounter == $repeatHeaders and $repeatHeaders > 0) {
                        if ($useHeadings) {
                            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons));
                        }
                        $headcounter = 0;
                    }
                    $headcounter++;
                    print "<tr>\n";
                    if ($class == "even") {
                        $class = "odd";
                    } else {
                        $class = "even";
                    }
                    unset($linkids);
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    // draw in the margin column where the links and metadata goes
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "<td class=\"head formulize-controls\">\n";
                    }
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $linkids[0]))) {
                            print "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $linkids[0] . "' id='delete_" . $linkids[0] . "' value='delete_" . $linkids[0] . "'>";
                        }
                        if ($useViewEntryLinks) {
                            print "<a href='" . $currentURL;
                            if (strstr($currentURL, "?")) {
                                // if params are already part of the URL...
                                print "&";
                            } else {
                                print "?";
                            }
                            print "ve=" . $linkids[0] . "' onclick=\"javascript:goDetails('" . $linkids[0] . "');return false;\" " . " class=\"loe-edit-entry\" alt=\"" . _formulize_DE_VIEWDETAILS . "\" title=\"" . _formulize_DE_VIEWDETAILS . "\" >";
                            print "&nbsp;</a>";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "</td>\n";
                    }
                    $column_counter = 0;
                    if ($columnWidth) {
                        $columnWidthParam = "style=\"width: {$columnWidth}" . "px\"";
                    } else {
                        $columnWidthParam = "";
                    }
                    for ($i = 0; $i < count($cols); $i++) {
                        //formulize_benchmark("drawing one column");
                        $col = $cols[$i];
                        $colhandle = $settings['columnhandles'][$i];
                        $classToUse = $class . " column column" . $i;
                        $cellRowAddress = $id + 2;
                        if ($i == 0) {
                            print "<td {$columnWidthParam} class=\"{$class} floating-column\" id='floatingcelladdress_{$cellRowAddress}'>\n";
                        }
                        print "<td {$columnWidthParam} class=\"{$classToUse}\" id=\"celladdress_" . $cellRowAddress . "_" . $i . "\">\n";
                        if ($col == "creation_uid" or $col == "mod_uid") {
                            $userObject = $member_handler->getUser(display($entry, $col));
                            if ($userObject) {
                                $nameToDisplay = $userObject->getVar('name') ? $userObject->getVar('name') : $userObject->getVar('uname');
                            } else {
                                $nameToDisplay = _FORM_ANON_USER;
                            }
                            $value = "<a href=\"" . XOOPS_URL . "/userinfo.php?uid=" . display($entry, $col) . "\" target=_blank>" . $nameToDisplay . "</a>";
                        } else {
                            $value = display($entry, $col);
                        }
                        // set in the display function, corresponds to the entry id of the record in the form where the current value was retrieved from.  If there is more than one local entry id, because of a one to many framework, then this will be an array that corresponds to the order of the values returned by display.
                        $currentColumnLocalId = $GLOBALS['formulize_mostRecentLocalId'];
                        // if we're supposed to display this column as an element... (only show it if they have permission to update this entry)
                        if (in_array($colhandle, $deColumns) and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
                            if ($frid) {
                                // need to work out which form this column belongs to, and use that form's entry ID.  Need to loop through the entry to find all possible internal IDs, since a subform situation would lead to multiple values appearing in a single cell, so multiple displayElement calls would be made each with their own internal ID.
                                foreach ($entry as $entryFormHandle => $entryFormData) {
                                    foreach ($entryFormData as $internalID => $entryElements) {
                                        $deThisIntId = false;
                                        foreach ($entryElements as $entryHandle => $values) {
                                            if ($entryHandle == $col) {
                                                // we found the element that we're trying to display
                                                if ($deThisIntId) {
                                                    print "\n<br />\n";
                                                }
                                                // could be a subform so we'd display multiple values
                                                if ($deDisplay) {
                                                    print '<div id="deDiv_' . $colhandle . '_' . $internalID . '">';
                                                    print getHTMLForList($values, $colhandle, $internalID, $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                                    print "</div>";
                                                } else {
                                                    displayElement("", $colhandle, $internalID);
                                                }
                                                $deThisIntId = true;
                                            }
                                        }
                                    }
                                }
                            } else {
                                // display based on the mainform entry id
                                if ($deDisplay) {
                                    print '<div id="deDiv_' . $colhandle . '_' . $linkids[0] . '">';
                                    print getHTMLForList($value, $colhandle, $linkids[0], $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                    print "</div>";
                                } else {
                                    displayElement("", $colhandle, $linkids[0]);
                                    // works for mainform only!  To work on elements from a framework, we need to figure out the form the element is from, and the entry ID in that form, which is done above
                                }
                            }
                            $GLOBALS['formulize_displayElement_LOE_Used'] = true;
                        } elseif ($col != "creation_uid" and $col != "mod_uid" and $col != "entry_id") {
                            print getHTMLForList($value, $col, $linkids[0], 0, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                        } else {
                            // no special formatting on the uid columns:
                            print $value;
                        }
                        print "</td>\n";
                        $column_counter++;
                    }
                    // handle inline custom buttons
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $linkids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            print "<td {$columnWidthParam} class={$class}>\n";
                            print "<center>{$caCode}</center>\n";
                            print "</td>\n";
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    print "</tr>\n";
                } else {
                    // this is a blank entry
                    $blankentries++;
                }
                // end of not "" check
            }
            // end of foreach data as entry
        }
        // end of if there is any data to draw
        print "</table></div>";
    } elseif ($listTemplate and !$settings['hlist']) {
        // USING A CUSTOM LIST TEMPLATE SO DO EVERYTHING DIFFERENTLY
        // print str_replace("\n", "<br />", $listTemplate); // debug code
        $mainFormHandle = key($data[key($data)]);
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (strstr($listTemplate, "displayElement")) {
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
        }
        if (isset($data)) {
            //for($entryCounter=$formulize_LOEPageStart;$entryCounter<$actualPageSize;$entryCounter++) {
            // setup the view name variables, with true only set for the last loaded view
            $viewNumber = 1;
            foreach ($settings['publishedviewnames'] as $id => $thisViewName) {
                $thisViewName = str_replace(" ", "_", $thisViewName);
                if ($id == $settings['lastloaded']) {
                    ${$thisViewName} = true;
                    ${'view' . $viewNumber} = true;
                } else {
                    ${$thisViewName} = false;
                    $view['view' . $viewNumber] = false;
                }
                $viewNumber++;
            }
            foreach ($data as $id => $entry) {
                //$entry = $data[$entryCounter];
                //$id=$entryCounter;
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    // Set up the variables for the link to the current entry, and the checkbox that can be used to select the current entry
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    $entry_id = $linkids[0];
                    // make a nice way of referring to this for in the eval'd code
                    $form_id = $fid;
                    // make a nice way of referring to this for in the eval'd code
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        $viewEntryLinkCode = "<a href='" . $currentURL;
                        if (strstr($currentURL, "?")) {
                            // if params are already part of the URL...
                            $viewEntryLinkCode .= "&";
                        } else {
                            $viewEntryLinkCode .= "?";
                        }
                        $viewEntryLinkCode .= "ve=" . $entry_id . "' onclick=\"javascript:goDetails('" . $entry_id . "');return false;\">";
                        $GLOBALS['formulize_viewEntryId'] = $entry_id;
                        // put into global scope so the function 'viewEntryLink' can pick it up if necessary
                        $GLOBALS['formulize_viewEntryLinkCode'] = $viewEntryLinkCode;
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $entry_id))) {
                            $selectionCheckbox = "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $entry_id . "' id='delete_" . $entry_id . "' value='delete_" . $entry_id . "'>";
                        } else {
                            $selectionCheckbox = "";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    $ids = internalRecordIds($entry, $mainFormHandle);
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $ids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            ${$thisCustomAction['handle']} = $caCode;
                            // assign the button code that was returned
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    include XOOPS_ROOT_PATH . "/modules/formulize/templates/screens/default/" . $screen->getVar('sid') . "/listtemplate.php";
                }
            }
        }
    }
    // END OF MASTER HIDELIST CONDITIONAL
    if ((!isset($data) or count($data) == $blankentries) and !$LOE_limit) {
        // if no data was returned, or the dataset was empty...
        print "<p><b>" . _formulize_DE_NODATAFOUND . "</b></p>\n";
    } elseif ($LOE_limit) {
        print "<p>" . _formulize_DE_LOE_LIMIT_REACHED1 . " <b>" . $LOE_limit . "</b> " . _formulize_DE_LOE_LIMIT_REACHED2 . " <a href=\"\" onclick=\"javascript:forceQ();return false;\">" . _formulize_DE_LOE_LIMIT_REACHED3 . "</a></p>\n";
    }
    if ($scrollBoxWasSet) {
        print "</div>";
    }
    formulize_benchmark("We're done");
}
Пример #14
0
function calcConnectionDirectConnection($first, $second, $startlimit, $maxdepth, $depth, $ignoredObjects, $ignoredPredicates, $fullconnection)
{
    $time = microtime(true);
    mysql_connect($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['password']);
    mysql_select_db($GLOBALS['db']);
    //fuer alte Links
    if (isset($_GET['maxdepth'])) {
        $maxdepth = $_GET['maxdepth'] + 1;
    }
    $foundconnection = false;
    $limit = $startlimit;
    $idcounter = 0;
    $htmlcounter = 0;
    $saveRow = array();
    //ignorierte Objekte/Praedikate kommen als Array an => Umrechnung in String fuer URL
    for ($i = 0; $i < count($ignoredObjects); $i++) {
        $permalinkIgnoreObjects .= '&amp;ignoreObject_' . $i . '=' . $ignoredObjects[$i];
    }
    for ($i = 0; $i < count($ignoredPredicates); $i++) {
        $permalinkIgnorePredicates .= '&amp;ignorePredicate_' . $i . '=' . $ignoredPredicates[$i];
    }
    //Ueberpruefung, ob gegebene Anfrage schon gespeichert ist
    include "queries.inc.php";
    $savedIndex = isSaved($first, $second, $limit, $maxdepth, $depth, $ignoredObjects, $ignoredPredicates);
    //Falls gegebene Anfrage schon gespeichert ist=> Ausgeben
    if (is_int($savedIndex)) {
        $lastdepth = -1;
        for ($i = 0; $i < count($queries[$savedIndex]['savedResult']['row']); $i++) {
            echo $lastdepth != $queries[$savedIndex]['savedResult']['depth'][$i] ? '<table style="border:solid 1px #FF8040;margin-left:2px;"><tr><td style="background-color:#e4e4e4;border:1px solid #CFCFCF;">Distance: ' . ($queries[$savedIndex]['savedResult']['depth'][$i] + 1) . '</td></tr>' : '';
            printResults($queries[$savedIndex]['savedResult']['row'][$i], $htmlcounter, $idcounter, $first, $second);
            echo $queries[$savedIndex]['savedResult']['depth'][$i] != $queries[$savedIndex]['savedResult']['depth'][$i + 1] || !isset($queries[$savedIndex]['savedResult']['depth'][$i + 1]) ? '</table><br>' : '';
            $lastdepth = $queries[$savedIndex]['savedResult']['depth'][$i];
        }
        echo 'This is a cached result. It was saved on ' . date('r', $queries[$savedIndex]['saveTime']) . '.<br>';
        $queries[$savedIndex]['clickCount']++;
        file_put_contents('queries.inc.php', "<?\n\$queries=" . var_export($queries, true) . ";\n?>");
    } else {
        if ($GLOBALS['usingClusterTable'] == true && $fullconnection == false) {
            $clusterConSwitch = calcConnectionCluster($first, $second, $maxdepth);
            if (is_Int($clusterConSwitch)) {
                $depth = $clusterConSwitch;
                echo 'We are now searching the complete data set for connections. Meanwhile, you may have a look at a preview result <a href="#" onclick="loadClusterConnection(\'ajax.php?f=6&amp;first=' . str_replace("%", "__perc__", $first) . '&amp;second=' . str_replace("%", "__perc__", $second) . $permalinkIgnoreObjects . $permalinkIgnorePredicates . '\')" title="Load Cluster Connection">here</a>.<br><br>';
                echo '<div id="clusterCon" style="display:none;"></div>';
                echo '<div id="ib_1000" style="position:absolute;top:500px;left:20%;width:200px;height:100px;"></div>';
                #echo ', or maybe you want to <a href="'.substr($_SERVER['PHP_SELF'],0,-strlen($_SERVER['SCRIPT_NAME'])).'index.php?firstObject='.$first.'&amp;secondObject='.$second.'&amp;limit='.$startlimit.'&amp;maxdistance='.$maxdepth.$permalinkIgnoreObjects.$permalinkIgnorePredicates.'&amp;fullc=true&amp;saved=saved">load the full Results</a>?<br><br>';
                $fullconnection = true;
            } else {
                if ($clusterConSwitch == 'notenoughdistance') {
                    echo 'For a Preview Result click <a href="#" onclick="loadClusterConnection(\'ajax.php?f=6&amp;first=' . str_replace("%", "__perc__", $first) . '&amp;second=' . str_replace("%", "__perc__", $second) . $permalinkIgnoreObjects . $permalinkIgnorePredicates . '\')" title="Load Cluster Connection">here</a>.<br>';
                    echo '<div id="clusterCon" style="display:none;"></div>';
                    echo '<div id="ib_0" style="position:absolute;top:500px;left:20%;width:200px;height:100px;"></div>';
                }
            }
        }
        if ($fullconnection == true || $GLOBALS['usingClusterTable'] == false) {
            ob_flush();
            flush();
            do {
                //Berechnung der Verbindung, falls dieses moeglich ist
                $res = mysql_query(getQuery($depth, $first, $second, $limit, $ignoredObjects, $ignoredPredicates)) or die(mysql_error());
                if (mysql_num_rows($res) > 0) {
                    $limit = $limit - mysql_num_rows($res);
                    $foundconnection = true;
                    echo '<table style="border:solid 1px #FF8040;margin-left:2px;"><tr><td style="background-color:#e4e4e4;border:1px solid #CFCFCF;">Distance: ' . ($depth + 1) . '</td></tr>';
                    while ($row = mysql_fetch_row($res)) {
                        printResults($row, $htmlcounter, $idcounter, $first, $second);
                        $saveRow['row'][] = $row;
                        $saveRow['depth'][] = $depth;
                    }
                    echo '</table><br>';
                } else {
                    if ($depth == $maxdepth - 1) {
                        echo "No Connection Found at max. Distance {$maxdepth} !<br><br>";
                        //f�r maximale Tiefe Fehlschlag ausgeben
                        #if ($GLOBALS['usingClusterTable']==true)
                        #calcConnectionCluster($first,$second,$maxdepth,true);
                    }
                }
                $depth++;
            } while ($depth < $maxdepth && $limit > 0);
            if ($foundconnection == true) {
                //Queries koennen abgespeichert werden, wenn eine Verbindung gefunden wurde
                echo '<span style="padding-left:2px;">Would you like to <a href="#" title="save Query" onmousedown="saveQuery(\'ajax.php?f=3&amp;first=' . str_replace("%", "__perc__", $first) . '&amp;second=' . str_replace("%", "__perc__", $second) . '&amp;limit=' . $startlimit . '&amp;maxdepth=' . $maxdepth . $permalinkIgnoreObjects . $permalinkIgnorePredicates . '&amp;depth=' . $depth . '\',\'' . str_replace('%', '__perc__', str_replace('"', '__quot__', serialize($saveRow))) . '\');">save</a> your query?</span><br>';
                echo '<span style="padding-left:2px;"><div id="save">&nbsp;</div></span><br>';
            }
        }
    }
    echo 'Result obtained in ' . round(microtime(true) - $time, 3) . ' seconds.<br>';
}
Пример #15
0
function runMainDemo(&$analytics)
{
    try {
        $profileId = '48994878';
        $dateStart = '2014-08-14';
        $dateEnd = '2014-08-21';
        $allSessions = getAllSessions($analytics, $profileId, $dateStart, $dateEnd);
        printResults($allSessions, 'Total sessions');
        $mobileSessions = getMobileSessions($analytics, $profileId, $dateStart, $dateEnd);
        printResults($mobileSessions, 'Mobile Sessions');
        print '<p><b>Percentage Mobile Sessions:</b></p>';
        print calcPercentageMobile($allSessions, $mobileSessions) . '%';
    } catch (apiServiceException $e) {
        // Error from the API.
        print 'There was an API error : ' . $e->getCode() . ' : ' . $e->getMessage();
    } catch (Exception $e) {
        print 'There was a general error : ' . $e->getMessage();
    }
}
Пример #16
0
$r = $engine->search($s);
printResults($r);
//A query where we want red dresses and a histogram of their
$s = new Search('red dress');
$s->addFacet(new HistFacet('price', 0, 500, 100));
$r = $engine->search($s);
printResults($r);
//A search with multiple keyed facets on the 'brand' field
$s = new Search('red dress');
$s->addFacet(new RangeFacet('price', 'price_range'));
$s->addFacet(new HistFacet('price', 0, 500, 100, 'price_hist'));
$r = $engine->search($s);
printResults($r);
//pass array of tags to exclude into the facet
$s = new Search('red dress');
$s->addFacet((new EnumFacet('brand', 200))->addEx('tag1')->addEx('tag2'));
$r = $engine->search($s);
printResults($r);
//search for 'red dress' with spelling correction turned off
$s = new Search('red dress');
$s->setCorrect(false);
$r = $engine->search($s);
printResults($r);
function printResults($r)
{
    echo "Got {$r->results->numfound} result(s)\n";
    if ($r->results->numfound > 0) {
        var_dump($r->results);
    }
    echo "\n-------------\n";
}
//        '7daysAgo',
//        'today',
//        'ga:sessions',
//        array(
//          'dimensions'  => 'ga:country',
//          'sort'        => '-ga:sessions',
//          'max-results' => 20
//        ) );
// }
function printResults(&$results)
{
    // Parses the response from the Core Reporting API and prints
    // the profile name and total sessions.
    if (count($results->getRows()) > 0) {
        // Get the profile name.
        $profileName = $results->getProfileInfo()->getProfileName();
        // Get the entry for the first entry in the first row.
        $rows = $results->getRows();
        $sessions = $rows[0][0];
        // Print the results.
        print "First view (profile) found: {$profileName}\n";
        print "Total sessions: {$sessions}\n";
    } else {
        print "No results found.\n";
    }
}
$analytics = getService();
$profile = getFirstProfileId($analytics);
$results = getResults($analytics, $profile);
printResults($results);
Пример #18
0
//        );
//}else{
//  $gaarr = array(
//        'filters' => 'ga:pagePath=@/local/',
//        'dimensions' => 'ga:pagePath,ga:userType',
//        'metrics' => 'ga:sessions',
//        'sort' => '-ga:sessions',
//        );
//}
$pagepath = '/ca/santaana-test-business-161-24415/';
//$_REQUEST['page_path']
$gaarr = array('filters' => 'ga:pagePath==/local' . $pagepath, 'dimensions' => 'ga:pagePath,ga:date', 'metrics' => 'ga:sessions', 'sort' => '-ga:date');
$garesults = getGAResults($analytics, $profile, '30daysAgo', 'yesterday', $gaarr);
echo '<pre>';
$alldata = printResults($results);
printResults($garesults);
$rows = $results->rows;
$pageviews = $rows[1][1];
$newUsers = $rows[1][3];
$users = $rows[1][4];
$sessionsPerUser = $rows[1][5];
?>

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {