Exemple #1
0
 /**
  * Destructor
  */
 public function __destruct()
 {
     foreach ($this->archives as $archive) {
         destroy($archive);
     }
     $this->archives = array();
 }
 public function __destruct()
 {
     foreach ($this->records as $record) {
         destroy($record);
     }
     $this->records = array();
 }
Exemple #3
0
function fixed($array)
{
    do {
        $word = $array[array_rand($array)];
        $word = ansiify($word);
        $word = caseify($word);
        $word = destroy($word);
    } while (strlen($word) < 4 || strlen($word) > 9);
    return $word;
}
 /**
  * Archive the IntranetSubNetwork count
  */
 function archiveDay($notification)
 {
     $archiveProcessing = $notification->getNotificationObject();
     $recordName = 'IntranetSubNetwork_networkNameExt';
     $labelSQL = "location_IntranetSubNetwork";
     $interestByIntranetSubNetwork = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableIntranetSubNetwork = $archiveProcessing->getDataTableFromArray($interestByIntranetSubNetwork);
     $archiveProcessing->insertBlobRecord($recordName, $tableIntranetSubNetwork->getSerialized());
     destroy($tableIntranetSubNetwork);
 }
Exemple #5
0
 /**
  * Archive the provider count
  */
 function archiveDay($notification)
 {
     $archiveProcessing = $notification->getNotificationObject();
     $recordName = 'Provider_hostnameExt';
     $labelSQL = "location_provider";
     $interestByProvider = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableProvider = $archiveProcessing->getDataTableFromArray($interestByProvider);
     $archiveProcessing->insertBlobRecord($recordName, $tableProvider->getSerialized());
     destroy($tableProvider);
 }
Exemple #6
0
 protected function archiveDayRecordInDatabase($archiveProcessing)
 {
     $tableCountry = $archiveProcessing->getDataTableFromArray($this->interestByCountry);
     $archiveProcessing->insertBlobRecord('UserCountry_country', $tableCountry->getSerialized());
     $archiveProcessing->insertNumericRecord('UserCountry_distinctCountries', $tableCountry->getRowsCount());
     destroy($tableCountry);
     $tableContinent = $archiveProcessing->getDataTableFromArray($this->interestByContinent);
     $archiveProcessing->insertBlobRecord('UserCountry_continent', $tableContinent->getSerialized());
     destroy($tableContinent);
 }
Exemple #7
0
 /** Build DataTable from array and archive it */
 private function archiveDataArray($keyword, &$data)
 {
     $dataTable = new Piwik_DataTable();
     foreach ($data as &$row) {
         $dataTable->addRow(new Piwik_SiteUsers_ExtendedDataTableRow(array(Piwik_DataTable_Row::COLUMNS => $row)));
     }
     $name = 'SiteUsers_' . $keyword;
     $this->archiveProcessing->insertBlobRecord($name, $dataTable->getSerialized());
     destroy($dataTable);
 }
Exemple #8
0
 public function destroy()
 {
     $this->_result = null;
     foreach ($this->_list as $m) {
         if (is_subclass_of($m, 'model')) {
             destroy($m);
         }
     }
     $this->free();
     $this->_list = array();
 }
Exemple #9
0
 protected function archiveDayRecordInDatabase($archiveProcessing)
 {
     $tableLocalTime = $archiveProcessing->getDataTableFromArray($this->interestByLocalTime);
     $this->makeSureAllHoursAreSet($tableLocalTime, $archiveProcessing);
     $archiveProcessing->insertBlobRecord('VisitTime_localTime', $tableLocalTime->getSerialized());
     destroy($tableLocalTime);
     $tableServerTime = $archiveProcessing->getDataTableFromArray($this->interestByServerTime);
     $this->makeSureAllHoursAreSet($tableServerTime, $archiveProcessing);
     $archiveProcessing->insertBlobRecord('VisitTime_serverTime', $tableServerTime->getSerialized());
     destroy($tableServerTime);
 }
Exemple #10
0
 /**
  * Archive the provider count
  */
 function archiveDay($notification)
 {
     $archiveProcessing = $notification->getNotificationObject();
     $recordName = 'Provider_hostnameExt';
     $labelSQL = "location_provider";
     $interestByProvider = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableProvider = $archiveProcessing->getDataTableFromArray($interestByProvider);
     $columnToSortByBeforeTruncation = Piwik_Archive::INDEX_NB_VISITS;
     $maximumRowsInDataTableLevelZero = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_providers;
     $archiveProcessing->insertBlobRecord($recordName, $tableProvider->getSerialized($maximumRowsInDataTableLevelZero, null, $columnToSortByBeforeTruncation));
     destroy($tableProvider);
 }
Exemple #11
0
function destroy()
{
    foreach (func_get_args() as $var) {
        if (is_object($var)) {
            $var->__destruct();
        } elseif (is_array($var)) {
            foreach ($var as $k => $v) {
                destroy($v);
            }
        }
        unset($var);
    }
}
 public function archiveDay($notification)
 {
     $this->archiveProcessing = $notification->getNotificationObject();
     if (!$this->archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) {
         return;
     }
     $recordName = 'VisitorInterest_timeGap';
     $tableTimegap = $this->getTableTimeGap();
     $this->archiveProcessing->insertBlobRecord($recordName, $tableTimegap->getSerialized());
     destroy($tableTimegap);
     $recordName = 'VisitorInterest_pageGap';
     $tablePagegap = $this->getTablePageGap();
     $this->archiveProcessing->insertBlobRecord($recordName, $tablePagegap->getSerialized());
     destroy($tablePagegap);
 }
Exemple #13
0
function destroy($dir) {
    $mydir = opendir($dir);
    while(false !== ($file = readdir($mydir))) {
        if($file != "." && $file != "..") {
            chmod($dir.$file, 0777);
            if(is_dir($dir.$file)) {
                chdir('.');
                destroy($dir.$file.'/');
                rmdir($dir.$file) or DIE("couldn't delete $dir$file<br />");
            }
            else
                unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
        }
    }
    closedir($mydir);
}
 function archiveDay($notification)
 {
     require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php';
     $archiveProcessing = $notification->getNotificationObject();
     $this->archiveProcessing = $archiveProcessing;
     $recordName = 'UserSettings_configuration';
     $labelSQL = "CONCAT(config_os, ';', config_browser_name, ';', config_resolution)";
     $interestByConfiguration = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableConfiguration = $archiveProcessing->getDataTableFromArray($interestByConfiguration);
     $archiveProcessing->insertBlobRecord($recordName, $tableConfiguration->getSerialized());
     destroy($tableConfiguration);
     $recordName = 'UserSettings_os';
     $labelSQL = "config_os";
     $interestByOs = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableOs = $archiveProcessing->getDataTableFromArray($interestByOs);
     $archiveProcessing->insertBlobRecord($recordName, $tableOs->getSerialized());
     destroy($tableOs);
     $recordName = 'UserSettings_browser';
     $labelSQL = "CONCAT(config_browser_name, ';', config_browser_version)";
     $interestByBrowser = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableBrowser = $archiveProcessing->getDataTableFromArray($interestByBrowser);
     $archiveProcessing->insertBlobRecord($recordName, $tableBrowser->getSerialized());
     $recordName = 'UserSettings_browserType';
     $tableBrowserType = $this->getTableBrowserByType($tableBrowser);
     $archiveProcessing->insertBlobRecord($recordName, $tableBrowserType->getSerialized());
     destroy($tableBrowser);
     destroy($tableBrowserType);
     $recordName = 'UserSettings_resolution';
     $labelSQL = "config_resolution";
     $interestByResolution = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableResolution = $archiveProcessing->getDataTableFromArray($interestByResolution);
     $tableResolution->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_UserSettings_keepStrlenGreater'));
     $archiveProcessing->insertBlobRecord($recordName, $tableResolution->getSerialized());
     $recordName = 'UserSettings_wideScreen';
     $tableWideScreen = $this->getTableWideScreen($tableResolution);
     $archiveProcessing->insertBlobRecord($recordName, $tableWideScreen->getSerialized());
     destroy($tableResolution);
     destroy($tableWideScreen);
     $recordName = 'UserSettings_plugin';
     $tablePlugin = $this->getDataTablePlugin();
     $archiveProcessing->insertBlobRecord($recordName, $tablePlugin->getSerialized());
     destroy($tablePlugin);
 }
Exemple #15
0
function done_testing()
{
    global $t;
    $funcs = get_defined_functions();
    $initialize = false;
    $finalize = false;
    if (in_array('initialize', $funcs['user'])) {
        $initialize = true;
    }
    if (in_array('finalize', $funcs['user'])) {
        $finalize = true;
    }
    if (in_array('build', $funcs['user'])) {
        build($t);
    }
    foreach ($funcs['user'] as $func) {
        # 予約された function
        if (in_array($func, array('build', 'destroy', 'initialize', 'finalize', 'done_testing'))) {
            continue;
        }
        # _function( ) は skip
        if (preg_match('/^_/', $func)) {
            continue;
        }
        if ($initialize) {
            initialize($t);
        }
        try {
            $t->diag("in function '{$func}'");
            $func($t);
        } catch (Exception $e) {
            $t->diag($e->getMessage() . " at {$func}( )");
            $t->fail();
        }
        if ($finalize) {
            finalize($t);
        }
    }
    if (in_array('destroy', $funcs['user'])) {
        destroy($t);
    }
}
Exemple #16
0
 /**
  * Daily archive: processes the report Visits by Provider
  */
 function archiveDay($notification)
 {
     $archiveProcessing = $notification->getNotificationObject();
     if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) {
         return;
     }
     $recordName = 'Provider_hostnameExt';
     $labelSQL = "log_visit.location_provider";
     $interestByProvider = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableProvider = $archiveProcessing->getDataTableFromArray($interestByProvider);
     $columnToSortByBeforeTruncation = Piwik_Archive::INDEX_NB_VISITS;
     $maximumRowsInDataTable = Zend_Registry::get('config')->General->datatable_archiving_maximum_rows_standard;
     $archiveProcessing->insertBlobRecord($recordName, $tableProvider->getSerialized($maximumRowsInDataTable, null, $columnToSortByBeforeTruncation));
     destroy($tableProvider);
 }
 /**
  * @param string $name
  * @param string|array of string $aValues
  * @return true
  */
 public function insertBlobRecord($name, $value)
 {
     if (is_array($value)) {
         $records = new Piwik_ArchiveProcessing_RecordArray($name, $value);
         foreach ($records->get() as $record) {
             $this->insertRecord($record);
         }
         destroy($records);
         return true;
     }
     if ($this->compressBlob) {
         $record = new Piwik_ArchiveProcessing_Record_Blob($name, $value);
     } else {
         $record = new Piwik_ArchiveProcessing_Record($name, $value);
     }
     $this->insertRecord($record);
     destroy($record);
     return true;
 }
Exemple #18
0
	protected function archiveDayRecordInDatabase($archiveProcessing)
	{
		$numericRecords = array(
			'Referers_distinctSearchEngines'	=> count($this->interestBySearchEngineAndKeyword),
			'Referers_distinctKeywords' 		=> count($this->interestByKeywordAndSearchEngine),
			'Referers_distinctCampaigns'		=> count($this->interestByCampaign),
			'Referers_distinctWebsites'			=> count($this->interestByWebsite),
			'Referers_distinctWebsitesUrls'		=> count($this->distinctUrls),
		);
		
		foreach($numericRecords as $name => $value)
		{
			$archiveProcessing->insertNumericRecord($name, $value);
		}
		
		$dataTable = $archiveProcessing->getDataTableSerialized($this->interestByType);
		$archiveProcessing->insertBlobRecord('Referers_type', $dataTable);
		destroy($dataTable);
		
		$blobRecords = array(
			'Referers_keywordBySearchEngine' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestBySearchEngineAndKeyword, $this->interestBySearchEngine),
			'Referers_searchEngineByKeyword' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByKeywordAndSearchEngine, $this->interestByKeyword),
			'Referers_keywordByCampaign' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByCampaignAndKeyword, $this->interestByCampaign),
			'Referers_urlByWebsite' => $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByWebsiteAndUrl, $this->interestByWebsite),
		);
		foreach($blobRecords as $recordName => $table )
		{
			$blob = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
			$archiveProcessing->insertBlobRecord($recordName, $blob);
			destroy($table);
		}
	}
Exemple #19
0
 /**
  * Called at the end of the archiving process.
  * Does some cleaning job in the database.
  */
 protected function postCompute()
 {
     parent::postCompute();
     $numericTable = $this->tableArchiveNumeric->getTableName();
     self::doPurgeOutdatedArchives($numericTable, $this->isArchiveTemporary());
     if (!isset($this->archives)) {
         return;
     }
     foreach ($this->archives as $archive) {
         destroy($archive);
     }
     $this->archives = array();
 }
Exemple #20
0
 /**
  * Called at the end of the archiving process.
  * Does some cleaning job in the database.
  */
 protected function postCompute()
 {
     parent::postCompute();
     $blobTable = $this->tableArchiveBlob->getTableName();
     $numericTable = $this->tableArchiveNumeric->getTableName();
     $key = 'lastPurge_' . $blobTable;
     $timestamp = Piwik_GetOption($key);
     if (!$timestamp || $timestamp < time() - 86400) {
         Piwik_SetOption($key, time());
         // we delete out of date daily archives from table, maximum once per day
         // we only delete archives processed that are older than 1 day, to not delete archives we just processed
         $yesterday = Piwik_Date::factory('yesterday')->getDateTime();
         $result = Piwik_FetchAll("\n\t\t\t\t\t\t\tSELECT idarchive\n\t\t\t\t\t\t\tFROM {$numericTable}\n\t\t\t\t\t\t\tWHERE name LIKE 'done%'\n\t\t\t\t\t\t\t\tAND value = " . Piwik_ArchiveProcessing::DONE_OK_TEMPORARY . "\n\t\t\t\t\t\t\t\tAND ts_archived < ?", array($yesterday));
         $idArchivesToDelete = array();
         if (!empty($result)) {
             foreach ($result as $row) {
                 $idArchivesToDelete[] = $row['idarchive'];
             }
             $query = "DELETE \n    \t\t\t\t\t\tFROM %s\n    \t\t\t\t\t\tWHERE idarchive IN (" . implode(',', $idArchivesToDelete) . ")\n    \t\t\t\t\t\t";
             Piwik_Query(sprintf($query, $blobTable));
             Piwik_Query(sprintf($query, $numericTable));
         }
         Piwik::log("Purging temporary archives: done [ purged archives older than {$yesterday} from {$blobTable} and {$numericTable} ] [Deleted IDs: " . implode(',', $idArchivesToDelete) . "]");
         // Deleting "Custom Date Range" reports after 1 day, since they can be re-processed
         // and would take up unecessary space
         $query = "DELETE \n    \t\t\t\t\tFROM %s\n    \t\t\t\t\tWHERE period = ?\n    \t\t\t\t\t\tAND ts_archived < ?";
         $bind = array(Piwik::$idPeriods['range'], $yesterday);
         Piwik_Query(sprintf($query, $blobTable), $bind);
         Piwik_Query(sprintf($query, $numericTable), $bind);
     } else {
         Piwik::log("Purging temporary archives: skipped.");
     }
     if (!isset($this->archives)) {
         return;
     }
     foreach ($this->archives as $archive) {
         destroy($archive);
     }
     $this->archives = array();
 }
Exemple #21
0
include_once dirname(__FILE__) . '/ressources/class.templates.inc';
include_once dirname(__FILE__) . '/ressources/class.ini.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . "/framework/frame.class.inc";
if (preg_match("#--verbose#", implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    ini_set('error_prepend_string', null);
    ini_set('error_append_string', null);
}
if (preg_match("#--force#", implode(" ", $argv))) {
    $GLOBALS["FORCE"] = true;
}
if ($argv[1] == "--destroy") {
    destroy();
    die;
}
function destroy()
{
    remove_initd();
    if (is_file("/etc/cron.d/sendmail")) {
        @unlink("/etc/cron.d/sendmail");
    }
    if (is_file("/usr/share/sendmail/sendmail")) {
        @copy("/usr/share/sendmail/sendmail", "/usr/share/sendmail/sendmail.bak");
        @unlink("/usr/share/sendmail/sendmail");
    }
    if (is_file("/etc/init.d/sendmail")) {
        if (!is_file("/etc/init.d/sendmail.bak")) {
            @copy("/etc/init.d/sendmail", "/etc/init.d/sendmail.bak");
Exemple #22
0
 /**
  * Daily archive of User Settings report. Processes reports for Visits by Resolution,
  * by Browser, Browser family, etc. Some reports are built from the logs, some reports
  * are superset of an existing report (eg. Browser family is built from the Browser report)
  *
  * @param Piwik_Event_Notification $notification  notification object
  * @return void
  */
 function archiveDay($notification)
 {
     require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php';
     $maximumRowsInDataTable = Piwik_Config::getInstance()->General['datatable_archiving_maximum_rows_standard'];
     $columnToSortByBeforeTruncation = Piwik_Archive::INDEX_NB_VISITS;
     $archiveProcessing = $notification->getNotificationObject();
     if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) {
         return;
     }
     $this->archiveProcessing = $archiveProcessing;
     $recordName = 'UserSettings_configuration';
     $labelSQL = "CONCAT(log_visit.config_os, ';', log_visit.config_browser_name, ';', log_visit.config_resolution)";
     $interestByConfiguration = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableConfiguration = $archiveProcessing->getDataTableFromArray($interestByConfiguration);
     $archiveProcessing->insertBlobRecord($recordName, $tableConfiguration->getSerialized($maximumRowsInDataTable, null, $columnToSortByBeforeTruncation));
     destroy($tableConfiguration);
     $recordName = 'UserSettings_os';
     $labelSQL = "log_visit.config_os";
     $interestByOs = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableOs = $archiveProcessing->getDataTableFromArray($interestByOs);
     $archiveProcessing->insertBlobRecord($recordName, $tableOs->getSerialized($maximumRowsInDataTable, null, $columnToSortByBeforeTruncation));
     destroy($tableOs);
     $recordName = 'UserSettings_browser';
     $labelSQL = "CONCAT(log_visit.config_browser_name, ';', log_visit.config_browser_version)";
     $interestByBrowser = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableBrowser = $archiveProcessing->getDataTableFromArray($interestByBrowser);
     $archiveProcessing->insertBlobRecord($recordName, $tableBrowser->getSerialized($maximumRowsInDataTable, null, $columnToSortByBeforeTruncation));
     $recordName = 'UserSettings_browserType';
     $tableBrowserType = $this->getTableBrowserByType($tableBrowser);
     $archiveProcessing->insertBlobRecord($recordName, $tableBrowserType->getSerialized());
     destroy($tableBrowser);
     destroy($tableBrowserType);
     $recordName = 'UserSettings_resolution';
     $labelSQL = "log_visit.config_resolution";
     $interestByResolution = $archiveProcessing->getArrayInterestForLabel($labelSQL);
     $tableResolution = $archiveProcessing->getDataTableFromArray($interestByResolution);
     $tableResolution->filter('ColumnCallbackDeleteRow', array('label', 'Piwik_UserSettings_keepStrlenGreater'));
     $archiveProcessing->insertBlobRecord($recordName, $tableResolution->getSerialized($maximumRowsInDataTable, null, $columnToSortByBeforeTruncation));
     $recordName = 'UserSettings_wideScreen';
     $tableWideScreen = $this->getTableWideScreen($tableResolution);
     $archiveProcessing->insertBlobRecord($recordName, $tableWideScreen->getSerialized());
     destroy($tableResolution);
     destroy($tableWideScreen);
     $recordName = 'UserSettings_plugin';
     $tablePlugin = $this->getDataTablePlugin();
     $archiveProcessing->insertBlobRecord($recordName, $tablePlugin->getSerialized());
     destroy($tablePlugin);
 }
Exemple #23
0
 function archiveDay($notification)
 {
     /**
      * @var Piwik_ArchiveProcessing_Day 
      */
     $archiveProcessing = $notification->getNotificationObject();
     $funnelDefinitions = Piwik_Funnels_API::getInstance()->getFunnels($archiveProcessing->idsite);
     $funnelDefinitions = $this->initializeStepData($funnelDefinitions);
     list($funnelDefinitions, $total) = $this->storeRefAndNextUrls($funnelDefinitions, $archiveProcessing);
     // Add the calculations of dropout
     foreach ($funnelDefinitions as $funnelDefinition) {
         $last_index = count($funnelDefinition['steps']) - 1;
         $idFunnel = $funnelDefinition['idfunnel'];
         $idGoal = $funnelDefinition['idgoal'];
         // get the goal conversions grouped by the converting action
         $goal_query = $archiveProcessing->queryConversionsBySegment('idaction_url');
         $goalConversions = array();
         while ($row = $goal_query->fetch()) {
             if ($row['idgoal'] == $idGoal) {
                 $goalConversions[$row['idaction_url']] = $row['nb_conversions'];
             }
         }
         for ($i = 0; $i <= $last_index; $i++) {
             $current_step =& $funnelDefinition['steps'][$i];
             $idStep = $current_step['idstep'];
             // record number of actions for the step
             $recordName = Piwik_Funnels::getRecordName('nb_actions', $idFunnel, $idStep);
             $archiveProcessing->insertNumericRecord($recordName, $current_step['nb_actions']);
             # Remove the previous step urls from the idaction_url_ref array and add their actions to the
             # count of actions moving from the previous step to this one
             if ($i > 0) {
                 $previous_step = $funnelDefinition['steps'][$i - 1];
                 $nb_prev_step_actions = 0;
                 foreach ($previous_step['idaction_url'] as $key => $value) {
                     if (isset($current_step['idaction_url_ref'][$key])) {
                         $nb_prev_step_actions += $current_step['idaction_url_ref'][$key]['value'];
                         unset($current_step['idaction_url_ref'][$key]);
                     }
                 }
                 $recordName = Piwik_Funnels::getRecordName('nb_next_step_actions', $idFunnel, $previous_step['idstep']);
                 $archiveProcessing->insertNumericRecord($recordName, $nb_prev_step_actions);
                 // calculate a percent of people continuing from the previous step to this
                 $recordName = Piwik_Funnels::getRecordName('percent_next_step_actions', $idFunnel, $previous_step['idstep']);
                 $archiveProcessing->insertNumericRecord($recordName, $this->percent($nb_prev_step_actions, $previous_step['nb_actions']));
             }
             if ($i < $last_index) {
                 $next_step = $funnelDefinition['steps'][$i + 1];
                 # Remove this step's next actions that are actions for the next funnel step
                 foreach ($current_step['idaction_url_next'] as $key => $value) {
                     if (isset($next_step['idaction_url'][$key])) {
                         unset($current_step['idaction_url_next'][$key]);
                     }
                 }
                 # Archive the next urls that aren't funnel steps
                 $idActionNext = new Piwik_DataTable();
                 $exitCount = 0;
                 foreach ($current_step['idaction_url_next'] as $id => $data) {
                     $idActionNext->addRowFromSimpleArray($data);
                     $exitCount += $data['value'];
                 }
                 $recordName = Piwik_Funnels::getRecordName('idaction_url_next', $idFunnel, $idStep);
                 $archiveProcessing->insertBlobRecord($recordName, $idActionNext->getSerialized());
                 destroy($idActionNext);
                 # and a sum of exit actions
                 $recordName = Piwik_Funnels::getRecordName('nb_exit', $idFunnel, $idStep);
                 $archiveProcessing->insertNumericRecord($recordName, $exitCount);
             }
             // Archive the referring urls that aren't funnel steps
             $idActionRef = new Piwik_DataTable();
             $entryCount = 0;
             foreach ($current_step['idaction_url_ref'] as $id => $data) {
                 $idActionRef->addRowFromSimpleArray($data);
                 $entryCount += $data['value'];
             }
             $recordName = Piwik_Funnels::getRecordName('idaction_url_ref', $idFunnel, $idStep);
             $archiveProcessing->insertBlobRecord($recordName, $idActionRef->getSerialized());
             destroy($idActionRef);
             # and a sum of entry actions
             $recordName = Piwik_Funnels::getRecordName('nb_entry', $idFunnel, $idStep);
             $archiveProcessing->insertNumericRecord($recordName, $entryCount);
         }
         // For the last step, the comparison is the goal itself
         $last_step = $funnelDefinition['steps'][$last_index];
         $idStep = $last_step['idstep'];
         $recordName = Piwik_Funnels::getRecordName('nb_next_step_actions', $idFunnel, $idStep);
         $nb_goal_actions = 0;
         foreach ($goalConversions as $key => $value) {
             if (isset($last_step['idaction_url_next'][$key])) {
                 $nb_goal_actions += $last_step['idaction_url_next'][$key]['value'];
                 unset($last_step['idaction_url_next'][$key]);
             }
         }
         $archiveProcessing->insertNumericRecord($recordName, $nb_goal_actions);
         $recordName = Piwik_Funnels::getRecordName('percent_next_step_actions', $idFunnel, $idStep);
         $archiveProcessing->insertNumericRecord($recordName, $this->percent($nb_goal_actions, $last_step['nb_actions']));
         # Archive the next urls that aren't funnel steps
         $idActionNext = new Piwik_DataTable();
         $exitCount = 0;
         foreach ($last_step['idaction_url_next'] as $id => $data) {
             $idActionNext->addRowFromSimpleArray($data);
             $exitCount += $data['value'];
         }
         $recordName = Piwik_Funnels::getRecordName('idaction_url_next', $idFunnel, $idStep);
         $archiveProcessing->insertBlobRecord($recordName, $idActionNext->getSerialized());
         destroy($idActionNext);
         # and a sum of exit actions
         $recordName = Piwik_Funnels::getRecordName('nb_exit', $idFunnel, $idStep);
         $archiveProcessing->insertNumericRecord($recordName, $exitCount);
         // Archive the total funnel actions
         $recordName = Piwik_Funnels::getRecordName('nb_actions', $idFunnel, false);
         $archiveProcessing->insertNumericRecord($recordName, $total);
         // What percent of people who visited the first funnel step converted at the end of the funnel?
         $recordName = Piwik_Funnels::getRecordName('conversion_rate', $idFunnel, false);
         $archiveProcessing->insertNumericRecord($recordName, $this->percent($nb_goal_actions, $funnelDefinition['steps'][0]['nb_actions']));
     }
 }
Exemple #24
0
 function __destruct()
 {
     destroy($this->value);
 }
Exemple #25
0
 /**
  * @group Core
  * @group DataTable
  */
 public function testSubDataTableIsDestructed()
 {
     $mockedDataTable = $this->getMock('Piwik_DataTable', array('__destruct'));
     $mockedDataTable->expects($this->once())->method('__destruct');
     $rowBeingDestructed = new Piwik_DataTable_Row();
     $rowBeingDestructed->setSubtable($mockedDataTable);
     destroy($rowBeingDestructed);
 }
 /**
  * @param Piwik_ArchiveProcessing $archiveProcessing
  * @return void
  */
 protected function archiveDayRecordInDatabase($archiveProcessing)
 {
     $recordName = 'CustomVariables_valueByName';
     $table = $archiveProcessing->getDataTableWithSubtablesFromArraysIndexedByLabel($this->interestByCustomVariablesAndValue, $this->interestByCustomVariables);
     $blob = $table->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable);
     $archiveProcessing->insertBlobRecord($recordName, $blob);
     destroy($table);
 }
 /**
  * Deletes (unsets) the datatable given its id and removes it from the manager
  * Subsequent get for this table will fail
  *
  * @param int $id
  */
 public function deleteTable($id)
 {
     if (isset($this->tables[$id])) {
         $this->setTableDeleted($id);
         destroy($this->tables[$id]);
     }
 }
Exemple #28
0
 protected function archiveDayRecordInDatabase($archiveProcessing)
 {
     $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_ACTION_URL]);
     $this->deleteInvalidSummedColumnsFromDataTable($dataTable);
     $s = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
     $archiveProcessing->insertBlobRecord('Actions_actions_url', $s);
     destroy($dataTable);
     $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_DOWNLOAD]);
     $this->deleteInvalidSummedColumnsFromDataTable($dataTable);
     $s = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
     $archiveProcessing->insertBlobRecord('Actions_downloads', $s);
     destroy($dataTable);
     $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_OUTLINK]);
     $this->deleteInvalidSummedColumnsFromDataTable($dataTable);
     $s = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
     $archiveProcessing->insertBlobRecord('Actions_outlink', $s);
     destroy($dataTable);
     $dataTable = Piwik_ArchiveProcessing_Day::generateDataTable($this->actionsTablesByType[Piwik_Tracker_Action::TYPE_ACTION_NAME]);
     $this->deleteInvalidSummedColumnsFromDataTable($dataTable);
     $s = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, $this->maximumRowsInSubDataTable, $this->columnToSortByBeforeTruncation);
     $archiveProcessing->insertBlobRecord('Actions_actions', $s);
     destroy($dataTable);
     unset($this->actionsTablesByType);
 }
Exemple #29
0
 /**
  * At destruction we free all memory
  */
 public function __destruct()
 {
     static $depth = 0;
     // destruct can be called several times
     if ($depth < self::MAXIMUM_DEPTH_LEVEL_ALLOWED && isset($this->rows)) {
         $depth++;
         foreach ($this->getRows() as $row) {
             destroy($row);
         }
         unset($this->rows);
         Piwik_DataTable_Manager::getInstance()->setTableDeleted($this->getId());
         $depth--;
     }
 }
Exemple #30
0
 /**
  * At destruction we free all memory
  */
 public function __destruct()
 {
     static $depth = 0;
     // destruct can be called several times
     if ($depth < self::$maximumDepthLevelAllowed && isset($this->rows)) {
         $depth++;
         foreach ($this->getRows() as $row) {
             destroy($row);
         }
         unset($this->rows);
         Piwik_DataTable_Manager::getInstance()->setTableDeleted($this->getId());
         $depth--;
     }
 }