Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.php - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e566b213ff236feadccd31eb3f667839f53fcffb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
 * PHP Configuration init
 */
error_reporting(E_ALL|E_NOTICE);
date_default_timezone_set('Europe/London');
define('PIWIK_INCLUDE_PATH', '.');

set_include_path(PIWIK_INCLUDE_PATH 
					. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs/'
					. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins/'
					. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/modules/'
					. PATH_SEPARATOR . get_include_path());

assert_options(ASSERT_ACTIVE, 	1);
assert_options(ASSERT_WARNING, 	1);
assert_options(ASSERT_BAIL, 	1);

/**
 * Error / exception handling functions
 */
require_once PIWIK_INCLUDE_PATH . "/modules/ErrorHandler.php";
set_error_handler('Piwik_ErrorHandler');
require_once PIWIK_INCLUDE_PATH . "/modules/ExceptionHandler.php";
set_exception_handler('Piwik_ExceptionHandler');

/**
 * Zend classes
 */
include "Zend/Exception.php";
include "Zend/Loader.php";
require_once "Zend/Debug.php";
require_once "Zend/Auth.php";
require_once "Zend/Auth/Adapter/DbTable.php";

/**
 * Piwik classes
 */
require_once "Timer.php";
$timer = new Piwik_Timer;
require_once "Piwik.php";

require_once "Access.php";
require_once "Auth.php";
require_once "PublicAPI.php";
require_once "Site.php";

//move into a init() method
Piwik::createConfigObject();

// database object
Piwik::createDatabaseObject();

// Create the log objects
Piwik::createLogObject();

//TODO move all DB related methods in a DB static class
Piwik::createDatabase();
Piwik::createDatabaseObject();
Piwik::dropTables(array(Piwik::prefixTable('log_visit'),Piwik::prefixTable('log_link_visit_action'),Piwik::prefixTable('log_action')));
Piwik::createTables();

// load plugins
Piwik_PluginsManager::getInstance()->setInstallPlugins(); //TODO plugins install to handle in a better way
Piwik::loadPlugins();

// Create auth object
$auth = Zend_Auth::getInstance();
$authAdapter = new Piwik_Auth();
$authAdapter->setTableName(Piwik::prefixTable('user'))
			->setIdentityColumn('login')
			->setCredentialColumn('password')
			->setCredentialTreatment('MD5(?)');

// Set the input credential values (e.g., from a login form)
$authAdapter->setIdentity('root')
            ->setCredential('nintendo');

// Perform the authentication query, saving the result
$access = new Piwik_Access($authAdapter);
Zend_Registry::set('access', $access);

Zend_Registry::get('access')->loadAccess();

Zend_Loader::loadClass('Piwik_Archive');
Zend_Loader::loadClass('Piwik_Date');

$test = new Piwik_Archive;
$period = new Piwik_Period_Day( Piwik_Date::today() );
$site = new Piwik_Site(1);
$test->setPeriod($period);
$test->setSite($site);
$test->get('toto0');
$test->get('toto1');

$test = new Piwik_Archive;
$period = new Piwik_Period_Day(Piwik_Date::today());
$site = new Piwik_Site(12);
$test->setPeriod($period);
$test->setSite($site);
$test->get('nb_visits');
$test->get('toto12');
echo "<br>Piwik_Period_Day" . $timer;

//$period = new Piwik_Period_Month(new Piwik_Date('2007-02-02'));
//$site = new Piwik_Site(2);
//$test->setPeriod($period);
//$test->setSite($site);
//$test->get('toto2');
//$test->get('toto3');
//echo "<br>Piwik_Period_Month" . $timer;


//$period = new Piwik_Period_Year(new Piwik_Date('2007-02-02'));
//$site = new Piwik_Site(2);
//$test->setPeriod($period);
//$test->setSite($site);
//$test->get('toto2');
//$test->get('toto3');
//echo "Piwik_Period_Year" .  $timer;

main();
//Piwik::uninstall();

//Piwik_Log::dump( Zend_Registry::get('db')->getProfiler()->getQueryProfiles() );

function displayProfiler()
{
	$profiler = Zend_Registry::get('db')->getProfiler();

	$totalTime    = $profiler->getTotalElapsedSecs();
	$queryCount   = $profiler->getTotalNumQueries();
	$longestTime  = 0;
	$longestQuery = null;
	
	foreach ($profiler->getQueryProfiles() as $query) {
	    if ($query->getElapsedSecs() > $longestTime) {
	        $longestTime  = $query->getElapsedSecs();
	        $longestQuery = $query->getQuery();
	    }
	}
	
	echo '<br>Executed ' . $queryCount . ' queries in ' . $totalTime . ' seconds' . "\n";
	echo '<br>Average query length: ' . $totalTime / $queryCount . ' seconds' . "\n";
	echo '<br>Queries per second: ' . $queryCount / $totalTime . "\n";
	echo '<br>Longest query length: ' . $longestTime . "\n";
	echo "<br>Longest query: \n" . $longestQuery . "\n";

	
}
function main()
{
	Piwik::log("Start process...");
	$api = Piwik_PublicApi::getInstance();
	
	$api->registerClass("Piwik_SitesManager");
	$api->registerClass("Piwik_UsersManager");
	
	$api->SitesManager->getSiteUrlsFromId(1);
	
	$api->SitesManager->addSite("test name site", array("http://localhost", "http://test.com"));
	
	
	Zend_Registry::get('access')->loadAccess();
	
	$api->UsersManager->deleteUser("login");
	$api->UsersManager->addUser("login", "password", "email@geage.com");
}
displayProfiler();
echo $timer;
?>
<br>
<br>
<br>
<a href="piwik.php?idsite=1&download=http://php.net/get&name=test download/ the file">test download </a>
<br>
<a href="piwik.php?idsite=1&download=http://php.net/get">test download - without name var</a>
<br>
<a href="piwik.php?idsite=1&link=http://php.net/&name=php.net website">test link php</a>
<br>
<a href="piwik.php?idsite=1&link=http://php.net/">test link php - without name var</a>
<br>
<!-- Piwik -->
<a href="http://piwik.org" title="Web analytics" onclick="window.open(this.href);return(false);">
<script language="javascript" src="piwik.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
	piwik_action_name = '';
	piwik_idsite = 1;
	piwik_url = "http://localhost/dev/piwiktrunk/piwik.php";
	piwik_log(piwik_action_name, piwik_idsite, piwik_url);
//-->
</script><object>
<noscript><p>Web analytics<img src="http://localhost/dev/piwiktrunk/piwik.php" style="border:0" /></p>
</noscript></object></a>
<!-- /Piwik -->