- I'm a Mac user whose preferred browser is OmniWeb booste. I've been frustrated that PN
does not track my browser.
- Sniffing User-Agent strings is not considered a good way to
determine what information to serve or how to serve it.
Whenever possible, It is better practice to test for the
specific function rather than the browser or platform. Search
Google for 'User Agent Browser War' for more information.
Backup and documentation:
- ALWAYS back up your files and database before making changes
- A great practice is to have a local install that you can
safely use for experimenting
- Document your hacks. This is a hack to core files and the
data base and it is almost definitely going to be overwritten
with upgrades and .
- Caveat: this hack to core files will NOT be something that
the developers are taking cares not to create conflicts.
How to do the hack (using OmniWeb on a PN 0.762 install as the example):
- Table changes:
Insert these values into the pn_counter table: browser, OmniWeb, 0
- Create needed defines:
- In /modules/Stats/lang/eng/global.php
- Add: define('_OMNIWEB','OmniWeb');
- In /modules/Stats/lang/eng/global.php
- Collect browser data
- In includes/legacy/counter.php
- Actually gets and counts browser data
- Look for ~ line 49 /* Get the Browser data */
- Since pretty much every browser in the world uses 'Mozilla'
in their User Agent string, need to make sure OmniWeb is not
counted here, so add the following to this initial line (~51)
that otherwise will lump things as Netscape:
Code
- ADD with the other exclusions (!ereg) the following:
Code
- Add to the elseif (ereg("BrowserName"...
Code
- In includes/legacy/counter.php
- Add to the display
- In modules/Stats/index.php
- Find code assembling data about browsers, ~ line 211 in
0.762:
Code
switch ($type) {
case "total":
switch ($var) {
case "hits":
$total = $count;
break;
}
case "browser":
switch ($var) {
- Insert the following snippet:
Code
- Find the code displaying the browser information ~ line 325+
in 0.762: OpenTable and echo '' ._BROWSERS. '':
- Add the following:
Code
echo "<tr><td><img
src=\"modules/$ModName/images/altavista.gif\"
alt=\"\" /></td><td> "._OMNIWEB.":
</td><td>".mk_percbar($omniweb[1],200,false,$ThemeSel,
"$omniweb[1] %")." $omniweb[1] %
($omniweb[0])</td></tr>\n";
- In modules/Stats/index.php
Caveats:
- I've only used this on a 'sandbox' install as a learning exercise.
- Do this at your own risk.
- If you find typos or errors, let me know and I'll correct this.
Peter
edited by: pheski, Nov 12, 2006 - 11:11 AM
--
Peace
______________________________________
The commonest cause of problems is solutions.