Version Description
Download this release
Release Info
Developer | supercleanse |
Plugin | Shortlinks by Pretty Links – Best WordPress Link Tracking Plugin |
Version | 1.3.11 |
Comparing to | |
See all releases |
Version 1.3.11
- classes/models/PrliClick.php +97 -0
- classes/models/PrliLink.php +214 -0
- classes/models/PrliReport.php +226 -0
- classes/models/PrliUtils.php +278 -0
- classes/models/models.inc.php +11 -0
- classes/views/prli-clicks/csv.php +24 -0
- classes/views/prli-clicks/list.php +106 -0
- classes/views/prli-links/edit.php +87 -0
- classes/views/prli-links/list.php +145 -0
- classes/views/prli-links/new.php +87 -0
- classes/views/prli-reports/form.php +38 -0
- classes/views/shared/errors.php +19 -0
- classes/views/shared/table-nav.php +93 -0
- images/arrow_down.png +0 -0
- images/arrow_up.png +0 -0
- images/bookmark.png +0 -0
- images/browser/abilon.png +0 -0
- images/browser/adobe.png +0 -0
- images/browser/akregator.png +0 -0
- images/browser/alcatel.png +0 -0
- images/browser/amaya.png +0 -0
- images/browser/amigavoyager.png +0 -0
- images/browser/analogx.png +0 -0
- images/browser/apt.png +0 -0
- images/browser/avant.png +0 -0
- images/browser/aweb.png +0 -0
- images/browser/bpftp.png +0 -0
- images/browser/bytel.png +0 -0
- images/browser/chimera.png +0 -0
- images/browser/chrome.png +0 -0
- images/browser/cyberdog.png +0 -0
- images/browser/da.png +0 -0
- images/browser/dillo.png +0 -0
- images/browser/doris.png +0 -0
- images/browser/dreamcast.png +0 -0
- images/browser/ecatch.png +0 -0
- images/browser/encompass.png +0 -0
- images/browser/epiphany.png +0 -0
- images/browser/ericsson.png +0 -0
- images/browser/feeddemon.png +0 -0
- images/browser/feedreader.png +0 -0
- images/browser/firefox.png +0 -0
- images/browser/flashget.png +0 -0
- images/browser/fpexpress.png +0 -0
- images/browser/fresco.png +0 -0
- images/browser/freshdownload.png +0 -0
- images/browser/frontpage.png +0 -0
- images/browser/galeon.png +0 -0
- images/browser/getright.png +0 -0
- images/browser/gnome.png +0 -0
- images/browser/gnus.png +0 -0
- images/browser/gozilla.png +0 -0
- images/browser/hotjava.png +0 -0
- images/browser/httrack.png +0 -0
- images/browser/ibrowse.png +0 -0
- images/browser/icab.png +0 -0
- images/browser/java.png +0 -0
- images/browser/jetbrains_omea.png +0 -0
- images/browser/kmeleon.png +0 -0
- images/browser/konqueror.png +0 -0
- images/browser/leechget.png +0 -0
- images/browser/lg.png +0 -0
- images/browser/lotusnotes.png +0 -0
- images/browser/lynx.png +0 -0
- images/browser/macweb.png +0 -0
- images/browser/mediaplayer.png +0 -0
- images/browser/motorola.png +0 -0
- images/browser/mozilla.png +0 -0
- images/browser/mplayer.png +0 -0
- images/browser/msie.png +0 -0
- images/browser/msie_large.png +0 -0
- images/browser/multizilla.png +0 -0
- images/browser/ncsa_mosaic.png +0 -0
- images/browser/neon.png +0 -0
- images/browser/netnewswire.png +0 -0
- images/browser/netpositive.png +0 -0
- images/browser/netscape.png +0 -0
- images/browser/netscape_large.png +0 -0
- images/browser/netshow.png +0 -0
- images/browser/newsfire.png +0 -0
- images/browser/newsgator.png +0 -0
- images/browser/newzcrawler.png +0 -0
- images/browser/nokia.png +0 -0
- images/browser/notavailable.png +0 -0
- images/browser/omniweb.png +0 -0
- images/browser/opera.png +0 -0
- images/browser/panasonic.png +0 -0
- images/browser/pdaphone.png +0 -0
- images/browser/philips.png +0 -0
- images/browser/phoenix.png +0 -0
- images/browser/pluck.png +0 -0
- images/browser/pulpfiction.png +0 -0
- images/browser/real.png +0 -0
- images/browser/rss.png +0 -0
- images/browser/rssbandit.png +0 -0
- images/browser/rssowl.png +0 -0
- images/browser/rssreader.png +0 -0
- images/browser/rssxpress.png +0 -0
- images/browser/safari.png +0 -0
- images/browser/sagem.png +0 -0
- images/browser/samsung.png +0 -0
- images/browser/sharp.png +0 -0
- images/browser/sharpreader.png +0 -0
- images/browser/shrook.png +0 -0
- images/browser/siemens.png +0 -0
- images/browser/sony.png +0 -0
- images/browser/staroffice.png +0 -0
- images/browser/subversion.png +0 -0
- images/browser/teleport.png +0 -0
- images/browser/trium.png +0 -0
- images/browser/unknown.png +0 -0
- images/browser/w3c.png +0 -0
- images/browser/webcopier.png +0 -0
- images/browser/webreaper.png +0 -0
- images/browser/webtv.png +0 -0
- images/browser/webzip.png +0 -0
- images/browser/winxbox.png +0 -0
- images/browser/wizz.png +0 -0
- images/forward_params.png +0 -0
- images/os/aix.png +0 -0
- images/os/amigaos.png +0 -0
- images/os/apple.png +0 -0
- images/os/atari.png +0 -0
- images/os/beos.png +0 -0
- images/os/bsd.png +0 -0
- images/os/bsdfreebsd.png +0 -0
- images/os/bsdi.png +0 -0
- images/os/bsdnetbsd.png +0 -0
- images/os/bsdopenbsd.png +0 -0
- images/os/commodore.png +0 -0
- images/os/cpm.png +0 -0
- images/os/debian.png +0 -0
- images/os/digital.png +0 -0
- images/os/dos.png +0 -0
- images/os/dreamcast.png +0 -0
- images/os/freebsd.png +0 -0
- images/os/gnu.png +0 -0
- images/os/hpux.png +0 -0
- images/os/ibm.png +0 -0
- images/os/imode.png +0 -0
- images/os/irix.png +0 -0
- images/os/java.png +0 -0
- images/os/kfreebsd.png +0 -0
- images/os/linux.png +0 -0
- images/os/linuxcentos.png +0 -0
- images/os/linuxdebian.png +0 -0
- images/os/linuxfedora.png +0 -0
- images/os/linuxgentoo.png +0 -0
- images/os/linuxmandr.png +0 -0
- images/os/linuxredhat.png +0 -0
- images/os/linuxsuse.png +0 -0
- images/os/linuxubuntu.png +0 -0
- images/os/mac.png +0 -0
- images/os/macintosh.png +0 -0
- images/os/macosx.png +0 -0
- images/os/netbsd.png +0 -0
- images/os/netware.png +0 -0
- images/os/next.png +0 -0
- images/os/openbsd.png +0 -0
- images/os/os2.png +0 -0
- images/os/osf.png +0 -0
- images/os/psp.png +0 -0
- images/os/qnx.png +0 -0
- images/os/riscos.png +0 -0
- images/os/sco.png +0 -0
- images/os/sunos.png +0 -0
- images/os/symbian.png +0 -0
- images/os/unix.png +0 -0
- images/os/unknown.png +0 -0
- images/os/vms.png +0 -0
- images/os/webtv.png +0 -0
- images/os/win.png +0 -0
- images/os/win16.png +0 -0
- images/os/win2000.png +0 -0
- images/os/win2003.png +0 -0
- images/os/win95.png +0 -0
- images/os/win98.png +0 -0
- images/os/wince.png +0 -0
- images/os/winlong.png +0 -0
- images/os/winme.png +0 -0
- images/os/winnt.png +0 -0
- images/os/winunknown.png +0 -0
- images/os/winxbox.png +0 -0
- images/os/winxp.png +0 -0
- images/pixel_track.png +0 -0
- images/pretty-link-add.png +0 -0
- images/pretty-link-med.png +0 -0
- images/pretty-link-small.png +0 -0
- images/url_icon.gif +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- includes/jquery/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- includes/jquery/css/ui-lightness/jquery-ui-1.7.1.custom.css +404 -0
- includes/jquery/js/jquery-1.3.2.min.js +19 -0
- includes/jquery/js/jquery-ui-1.7.1.custom.min.js +273 -0
- includes/php/php_browsecap.ini +16810 -0
- includes/version-2-ichor/README.txt +8 -0
- includes/version-2-ichor/js/README.txt +12 -0
- includes/version-2-ichor/js/json/json2.js +461 -0
- includes/version-2-ichor/js/swfobject.js +5 -0
- includes/version-2-ichor/open-flash-chart.swf +0 -0
- pretty-link.php +441 -0
- prli-clicks.php +168 -0
- prli-config.php +13 -0
- prli-image-lookups.php +136 -0
- prli-links.php +233 -0
- prli-options.php +73 -0
- prli-reports.php +9 -0
- prli.php +18 -0
- readme.txt +93 -0
classes/models/PrliClick.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliClick
|
3 |
+
{
|
4 |
+
function table_name()
|
5 |
+
{
|
6 |
+
global $wpdb;
|
7 |
+
return $wpdb->prefix . 'prli_clicks';
|
8 |
+
}
|
9 |
+
|
10 |
+
function get_ip_exclude_list()
|
11 |
+
{
|
12 |
+
$exclude_list = get_option('prli_exclude_ips');
|
13 |
+
$exclude_list = preg_replace('#[ \t]#','',$exclude_list);
|
14 |
+
|
15 |
+
if($exclude_list)
|
16 |
+
return "'" . implode("','", explode(',',$exclude_list)) . "'";
|
17 |
+
else
|
18 |
+
return '';
|
19 |
+
}
|
20 |
+
|
21 |
+
function get_exclude_where_clause( $starts_with = " WHERE")
|
22 |
+
{
|
23 |
+
$exclude_list = $this->get_ip_exclude_list();
|
24 |
+
|
25 |
+
if( $exclude_list != '')
|
26 |
+
return $starts_with . ' cl.ip NOT IN (' . $exclude_list . ')';
|
27 |
+
else
|
28 |
+
return '';
|
29 |
+
}
|
30 |
+
|
31 |
+
function getOne( $id )
|
32 |
+
{
|
33 |
+
global $wpdb, $prli_link;
|
34 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
35 |
+
$query = 'SELECT cl.*, li.name as link_name FROM ' . $this->table_name() . ' cl, ' . $prli_link->table_name() . ' li WHERE li.id = cl.link_id AND id=' . $id . $this->get_exclude_where_clause( ' AND' );
|
36 |
+
|
37 |
+
return $wpdb->get_row($query);
|
38 |
+
}
|
39 |
+
|
40 |
+
// SELECT cl.*,li.name as link_name FROM wp_prli_clicks cl, wp_prli_links li WHERE li.id = cl.link_id ORDER BY created_at DESC
|
41 |
+
function getAll($where = "")
|
42 |
+
{
|
43 |
+
global $wpdb, $prli_link;
|
44 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
45 |
+
$where = $this->get_exclude_where_clause( ' AND' ) . $where;
|
46 |
+
$query = 'SELECT cl.*, li.name as link_name FROM ' . $this->table_name() . ' cl, ' . $prli_link->table_name() . ' li WHERE li.id = cl.link_id' . $where;
|
47 |
+
return $wpdb->get_results($query);
|
48 |
+
}
|
49 |
+
|
50 |
+
// Pagination Methods
|
51 |
+
function getRecordCount($where="")
|
52 |
+
{
|
53 |
+
global $wpdb, $prli_link;
|
54 |
+
$where = $this->get_exclude_where_clause( ' WHERE' ).$where;
|
55 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name() . ' cl'. $where;
|
56 |
+
return $wpdb->get_var($query);
|
57 |
+
}
|
58 |
+
|
59 |
+
function getPageCount($p_size, $where="")
|
60 |
+
{
|
61 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
62 |
+
}
|
63 |
+
|
64 |
+
function getPage($current_p,$p_size, $where = "")
|
65 |
+
{
|
66 |
+
global $wpdb, $prli_link;
|
67 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
68 |
+
$end_index = $current_p * $p_size;
|
69 |
+
$start_index = $end_index - $p_size;
|
70 |
+
$where = $this->get_exclude_where_clause( ' AND' ) . $where;
|
71 |
+
$query = 'SELECT cl.*, li.name as link_name FROM ' . $this->table_name() . ' cl, ' . $prli_link->table_name() . ' li WHERE li.id = cl.link_id' . $where . ' LIMIT ' . $start_index . ',' . $p_size . ';';
|
72 |
+
$results = $wpdb->get_results($query);
|
73 |
+
return $results;
|
74 |
+
}
|
75 |
+
|
76 |
+
function generateUniqueVisitorId($num_chars = 6)
|
77 |
+
{
|
78 |
+
global $wpdb, $prli_utils;
|
79 |
+
|
80 |
+
// We're doing a base 36 hash which is why we're always doing everything by 36
|
81 |
+
$max_vuid_value = pow(36,$num_chars);
|
82 |
+
$min_vuid_value = 37;
|
83 |
+
$vuid = base_convert( mt_rand($min_vuid_value,$max_vuid_value), 10, 36 );
|
84 |
+
|
85 |
+
$query = "SELECT DISTINCT vuid FROM ".$this->table_name();
|
86 |
+
$vuids = $wpdb->get_col($query,0);
|
87 |
+
|
88 |
+
// It is highly unlikely that we'll ever see 2 identical random vuids
|
89 |
+
// but just in case, here's some code to prevent collisions
|
90 |
+
while( in_array($vuid,$vuids) )
|
91 |
+
$vuid = base_convert( mt_rand($min_vuid_value,$max_vuid_value), 10, 36 );
|
92 |
+
|
93 |
+
return $vuid;
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
?>
|
classes/models/PrliLink.php
ADDED
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliLink
|
3 |
+
{
|
4 |
+
function table_name()
|
5 |
+
{
|
6 |
+
global $wpdb;
|
7 |
+
return $wpdb->prefix . 'prli_links';
|
8 |
+
}
|
9 |
+
|
10 |
+
function create( $values )
|
11 |
+
{
|
12 |
+
global $wpdb, $wp_rewrite;
|
13 |
+
|
14 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$values['slug']);
|
15 |
+
$query = 'INSERT INTO ' . $this->table_name() .
|
16 |
+
' (url,slug,name,param_forwarding,param_struct,redirect_type,description,track_as_img,created_at) VALUES (\'' .
|
17 |
+
$values['url'] . '\',\'' .
|
18 |
+
$values['slug'] . '\',\'' .
|
19 |
+
$values['name'] . '\',\'' .
|
20 |
+
$values['param_forwarding'] . '\',\'' .
|
21 |
+
$values['param_struct'] . '\',\'' .
|
22 |
+
$values['redirect_type'] . '\',\'' .
|
23 |
+
$values['description'] . '\',' .
|
24 |
+
(int)isset($values['track_as_img']) . ',' .
|
25 |
+
'NOW())';
|
26 |
+
$query_results = $wpdb->query($query);
|
27 |
+
$wp_rewrite->flush_rules();
|
28 |
+
return $query_results;
|
29 |
+
}
|
30 |
+
|
31 |
+
function update( $id, $values )
|
32 |
+
{
|
33 |
+
global $wpdb, $wp_rewrite;
|
34 |
+
|
35 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$values['slug']);
|
36 |
+
$query = 'UPDATE ' . $this->table_name() .
|
37 |
+
' SET url=\'' . $values['url'] . '\', ' .
|
38 |
+
' slug=\'' . $values['slug'] . '\', ' .
|
39 |
+
' name=\'' . $values['name'] . '\', ' .
|
40 |
+
' param_forwarding=\'' . $values['param_forwarding'] . '\', ' .
|
41 |
+
' param_struct=\'' . $values['param_struct'] . '\', ' .
|
42 |
+
' redirect_type=\'' . $values['redirect_type'] . '\', ' .
|
43 |
+
' description=\'' . $values['description'] . '\', ' .
|
44 |
+
' track_as_img=' . (int)isset($values['track_as_img']) .
|
45 |
+
' WHERE id='.$id;
|
46 |
+
$query_results = $wpdb->query($query);
|
47 |
+
$wp_rewrite->flush_rules();
|
48 |
+
return $query_results;
|
49 |
+
}
|
50 |
+
|
51 |
+
function destroy( $id )
|
52 |
+
{
|
53 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
54 |
+
global $wpdb, $prli_click, $wp_rewrite;
|
55 |
+
|
56 |
+
$reset = 'DELETE FROM ' . $prli_click->table_name() . ' WHERE link_id=' . $id;
|
57 |
+
$destroy = 'DELETE FROM ' . $this->table_name() . ' WHERE id=' . $id;
|
58 |
+
|
59 |
+
$wp_rewrite->flush_rules();
|
60 |
+
|
61 |
+
$wpdb->query($reset);
|
62 |
+
return $wpdb->query($destroy);
|
63 |
+
}
|
64 |
+
|
65 |
+
function reset( $id )
|
66 |
+
{
|
67 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
68 |
+
global $wpdb, $wp_rewrite, $prli_click;
|
69 |
+
|
70 |
+
$reset = 'DELETE FROM ' . $prli_click->table_name() . ' WHERE link_id=' . $id;
|
71 |
+
return $wpdb->query($reset);
|
72 |
+
}
|
73 |
+
|
74 |
+
function getOneFromSlug( $slug )
|
75 |
+
{
|
76 |
+
global $wpdb;
|
77 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
78 |
+
$query = 'SELECT * FROM ' . $this->table_name() . ' WHERE slug=\'' . $slug . '\'';
|
79 |
+
return $wpdb->get_row($query);
|
80 |
+
}
|
81 |
+
|
82 |
+
function getOne( $id )
|
83 |
+
{
|
84 |
+
global $wpdb, $prli_click;
|
85 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
86 |
+
$query = 'SELECT li.*, (SELECT COUNT(*) FROM ' . $click_table . ' cl WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks FROM ' . $this->table_name() . ' li WHERE id=' . $id . ';';
|
87 |
+
return $wpdb->get_row($query);
|
88 |
+
}
|
89 |
+
|
90 |
+
function getAll()
|
91 |
+
{
|
92 |
+
global $wpdb, $prli_click;
|
93 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
94 |
+
$query = 'SELECT li.*, (SELECT COUNT(*) FROM ' . $click_table . ' cl WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks FROM ' . $this->table_name() . ' li;';
|
95 |
+
return $wpdb->get_results($query);
|
96 |
+
}
|
97 |
+
|
98 |
+
// Pagination Methods
|
99 |
+
function getRecordCount($where="")
|
100 |
+
{
|
101 |
+
global $wpdb;
|
102 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name() . $where;
|
103 |
+
return $wpdb->get_var($query);
|
104 |
+
}
|
105 |
+
|
106 |
+
function getPageCount($p_size, $where="")
|
107 |
+
{
|
108 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
109 |
+
}
|
110 |
+
|
111 |
+
function getPage($current_p,$p_size, $where = "")
|
112 |
+
{
|
113 |
+
global $wpdb, $prli_click;
|
114 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
115 |
+
$end_index = $current_p * $p_size;
|
116 |
+
$start_index = $end_index - $p_size;
|
117 |
+
$query = 'SELECT li.*, (SELECT COUNT(*) FROM ' . $click_table . ' cl WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks FROM ' . $this->table_name() . ' li' . $where . ' LIMIT ' . $start_index . ',' . $p_size . ';';
|
118 |
+
$results = $wpdb->get_results($query);
|
119 |
+
return $results;
|
120 |
+
}
|
121 |
+
|
122 |
+
/** I'm generating a slug that is by default 2-3 characters long.
|
123 |
+
* This gives us a possibility of 36^3 - 37 = 46,619 possible
|
124 |
+
* random slugs. That should be *more* than enough slugs for
|
125 |
+
* any website -- if I get any feedback that we need more then
|
126 |
+
* I can always make a config option to raise the # of chars.
|
127 |
+
*/
|
128 |
+
function generateValidSlug($num_chars = 3)
|
129 |
+
{
|
130 |
+
global $wpdb, $prli_utils;
|
131 |
+
|
132 |
+
// We're doing a base 36 hash which is why we're always doing everything by 36
|
133 |
+
$max_slug_value = pow(36,$num_chars);
|
134 |
+
$min_slug_value = 37; // we want to have at least 2 characters in the slug
|
135 |
+
$slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
|
136 |
+
|
137 |
+
$query = "SELECT slug FROM " . $this->table_name(); // . " WHERE slug='" . $slug . "'";
|
138 |
+
$slugs = $wpdb->get_col($query,0);
|
139 |
+
|
140 |
+
// It is highly unlikely that we'll ever see 2 identical random slugs
|
141 |
+
// but just in case, here's some code to prevent collisions
|
142 |
+
while( in_array($slug,$slugs) or !$prli_utils->slugIsAvailable($slug) )
|
143 |
+
$slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
|
144 |
+
|
145 |
+
return $slug;
|
146 |
+
}
|
147 |
+
|
148 |
+
function get_pretty_link_url($slug)
|
149 |
+
{
|
150 |
+
global $prli_blogurl;
|
151 |
+
|
152 |
+
$link = $this->getOneFromSlug($slug);
|
153 |
+
|
154 |
+
if((isset($link->param_forwarding) and $link->param_forwarding == 'custom') and
|
155 |
+
(isset($link->track_as_img) and $link->track_as_img == 1))
|
156 |
+
return "<img src=\"".$prli_blogurl . '/' . $link->slug . $link->param_struct . "\" width=\"1\" height=\"1\" style=\"display: none\" />";
|
157 |
+
else if((!isset($link->param_forwarding) or $link->param_forwarding != 'custom') and
|
158 |
+
(isset($link->track_as_img) and $link->track_as_img == 1))
|
159 |
+
return "<img src=\"".$prli_blogurl . '/' . $link->slug . "\" width=\"1\" height=\"1\" style=\"display: none\" />";
|
160 |
+
else if((isset($link->param_forwarding) and $link->param_forwarding == 'custom') and
|
161 |
+
(!isset($link->track_as_img) or $link->track_as_img == 0))
|
162 |
+
return $prli_blogurl . '/' . $link->slug . $link->param_struct;
|
163 |
+
else
|
164 |
+
return $prli_blogurl . '/' . $link->slug;
|
165 |
+
}
|
166 |
+
|
167 |
+
function validate( $values )
|
168 |
+
{
|
169 |
+
global $wpdb, $prli_utils;
|
170 |
+
|
171 |
+
$errors = array();
|
172 |
+
if( ( $values['url'] == null or $values['url'] == '') and $values['track_as_img'] != 'on' )
|
173 |
+
$errors[] = "Target URL can't be blank -- unless this Pretty Link is being used as a tracking pixel (see Advanced Options on this page)";
|
174 |
+
|
175 |
+
if( $values['slug'] == null or $values['slug'] == '' )
|
176 |
+
$errors[] = "Pretty Link can't be blank";
|
177 |
+
|
178 |
+
if( !empty($values['url']) and !preg_match('/^http.?:\/\/.*\..*$/', $values['url'] ) )
|
179 |
+
$errors[] = "Link URL must be a correctly formatted url";
|
180 |
+
|
181 |
+
if( !preg_match('/^[a-zA-Z0-9\.\-_]+$/', $values['slug'] ) )
|
182 |
+
$errors[] = "Pretty Link must not contain spaces or special characters";
|
183 |
+
|
184 |
+
if($values['id'] != null and $values['id'] != '')
|
185 |
+
$query = "SELECT slug FROM " . $this->table_name() . " WHERE slug='" . $values['slug'] . "' AND id <> " . $values['id'];
|
186 |
+
else
|
187 |
+
$query = "SELECT slug FROM " . $this->table_name() . " WHERE slug='" . $values['slug'] . "'";
|
188 |
+
|
189 |
+
$slug_already_exists = $wpdb->get_var($query);
|
190 |
+
|
191 |
+
if( $slug_already_exists or !$prli_utils->slugIsAvailable($values['slug']) )
|
192 |
+
$errors[] = "This pretty link slug is already taken, please choose a different one";
|
193 |
+
|
194 |
+
if( isset($values['param_forwarding']) and $values['param_forwarding'] == 'custom' and empty($values['param_struct']) )
|
195 |
+
$errors[] = "If Custom Parameter Forwarding has been selected then you must specify a forwarding format.";
|
196 |
+
|
197 |
+
if( isset($values['param_forwarding']) and $values['param_forwarding'] == 'custom' and !preg_match('#%.*?%#', $values['param_struct']) )
|
198 |
+
$errors[] = "Your parameter forwarding must have at least one parameter specified in the format ex: <code>/%var1%/%var_two%/%varname3% ...</code>";
|
199 |
+
|
200 |
+
/*
|
201 |
+
if(isset($values['track_as_img']) and $values['track_as_img'] == 'on' and $values['url'] != null and $values['url'] != '')
|
202 |
+
{
|
203 |
+
$size = getimagesize($values['url']);
|
204 |
+
if(!preg_match('#image#',$size['mime']))
|
205 |
+
{
|
206 |
+
$errors[] = "If you want to track this pretty link as an image then your target url must be an image (png, jpeg, gif, etc.)";
|
207 |
+
}
|
208 |
+
}
|
209 |
+
*/
|
210 |
+
|
211 |
+
return $errors;
|
212 |
+
}
|
213 |
+
}
|
214 |
+
?>
|
classes/models/PrliReport.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//include PRLI_PATH.'/includes/version-2-ichor/php-ofc-library/open-flash-chart.php';
|
4 |
+
|
5 |
+
class PrliReport {
|
6 |
+
|
7 |
+
function setupClickReport($start_timestamp,$end_timestamp, $link_id = "all", $type = "all")
|
8 |
+
{
|
9 |
+
global $wpdb, $prli_utils, $prli_click;
|
10 |
+
|
11 |
+
$clicks_table = $wpdb->prefix . "prli_clicks";
|
12 |
+
$links_table = $wpdb->prefix . "prli_links";
|
13 |
+
|
14 |
+
// Scrub times and leave the dates
|
15 |
+
$start_timestamp = mktime(0, 0, 0, date('n', $start_timestamp), date('j', $start_timestamp), date('Y', $start_timestamp));
|
16 |
+
$end_timestamp = mktime(0, 0, 0, date('n', $end_timestamp), date('j', $end_timestamp), date('Y', $end_timestamp) );
|
17 |
+
|
18 |
+
$day_timestamp = $start_timestamp;
|
19 |
+
$data_array = array();
|
20 |
+
|
21 |
+
while($day_timestamp <= ($end_timestamp + 60*60*24))
|
22 |
+
{
|
23 |
+
$dyear = date('Y',$day_timestamp);
|
24 |
+
$dmon = date('n',$day_timestamp);
|
25 |
+
$ddom = date('j',$day_timestamp);
|
26 |
+
|
27 |
+
$query = "SELECT count(*) FROM $clicks_table cl WHERE cl.created_at BETWEEN '$dyear-$dmon-$ddom 00:00:00' AND '$dyear-$dmon-$ddom 23:59:59'" . $prli_click->get_exclude_where_clause( ' AND' );
|
28 |
+
|
29 |
+
if($link_id != "all")
|
30 |
+
{
|
31 |
+
$query .= " AND link_id=$link_id";
|
32 |
+
}
|
33 |
+
|
34 |
+
if($type == "unique")
|
35 |
+
{
|
36 |
+
$query .= " AND first_click=1";
|
37 |
+
}
|
38 |
+
|
39 |
+
$data_array[date("Y-n-j",$day_timestamp)] = (int)$wpdb->get_var($query);
|
40 |
+
$day_timestamp += 60*60*24; // Advance one day
|
41 |
+
}
|
42 |
+
|
43 |
+
$top_click_count = $prli_utils->getTopValue(array_values($data_array));
|
44 |
+
|
45 |
+
if($link_id == "all")
|
46 |
+
$link_slug = "all links";
|
47 |
+
else
|
48 |
+
$link_slug = "'/".$wpdb->get_var("SELECT slug FROM $links_table WHERE id=$link_id") . "'";
|
49 |
+
|
50 |
+
if($type == "all")
|
51 |
+
$type_string = "All hits";
|
52 |
+
else
|
53 |
+
$type_string = "Unique hits";
|
54 |
+
|
55 |
+
$json_array = array(
|
56 |
+
"elements" => array( array(
|
57 |
+
"type" => "line",
|
58 |
+
"values" => array_values($data_array),
|
59 |
+
"dot-style" => array(
|
60 |
+
"type" => "dot",
|
61 |
+
"dot-size" => 4,
|
62 |
+
"colour" => "#ffc94e",
|
63 |
+
"halo-size" => 1,
|
64 |
+
"tip" => "#val# $type_string"
|
65 |
+
),
|
66 |
+
"width" => 2
|
67 |
+
) ),
|
68 |
+
"title" => array(
|
69 |
+
"text" => 'Pretty Link: '.$type_string.' on '.$link_slug. ' between ' . date("Y-n-j",$start_timestamp) . ' and ' . date("Y-n-j",$end_timestamp),
|
70 |
+
"style" => "font-size: 16px; font-weight: bold; color: #3030d0; text-align: center; padding-bottom: 5px;"
|
71 |
+
),
|
72 |
+
"bg_colour" => "-1",
|
73 |
+
"y_axis" => array(
|
74 |
+
"min" => 0,
|
75 |
+
"max" => $top_click_count,
|
76 |
+
"steps" => (int)(($top_click_count>=10)?$top_click_count/10:1),
|
77 |
+
"colour" => "#A2ACBA"
|
78 |
+
),
|
79 |
+
"x_axis" => array(
|
80 |
+
"colour" => "#A2ACBA",
|
81 |
+
"grid-colour" => "#ffefa7",
|
82 |
+
"offset" => false,
|
83 |
+
"steps" => 4,
|
84 |
+
"labels" => array(
|
85 |
+
"steps" => 2,
|
86 |
+
"rotate" => 45,
|
87 |
+
"colour" => "#000000",
|
88 |
+
"labels" => array_keys($data_array)
|
89 |
+
)
|
90 |
+
)
|
91 |
+
);
|
92 |
+
|
93 |
+
return $this->prli_json_encode($json_array);
|
94 |
+
|
95 |
+
/*
|
96 |
+
$title = new title('Pretty Link: '.$type_string.' on '.$link_slug. ' between ' . date("Y-n-j",$start_timestamp) . ' and ' . date("Y-n-j",$end_timestamp));
|
97 |
+
|
98 |
+
$title->set_style('font-size: 16px; font-weight: bold; color: #3030d0; text-align: center; padding-bottom: 5px;');
|
99 |
+
|
100 |
+
$default_dot = new dot();
|
101 |
+
$default_dot->size(4);
|
102 |
+
//$default_dot->rotation(-15);
|
103 |
+
//$default_dot->hollow(false);
|
104 |
+
$default_dot->colour('#ffc94e');
|
105 |
+
$default_dot->halo_size(1);
|
106 |
+
$default_dot->tooltip( '#val# Hits' );
|
107 |
+
|
108 |
+
$line = new line();
|
109 |
+
$line->set_default_dot_style($default_dot);
|
110 |
+
$line->set_values( array_values($data_array) );
|
111 |
+
$line->set_width(2);
|
112 |
+
|
113 |
+
$y = new y_axis();
|
114 |
+
$y->set_range( 0, $top_click_count, (int)(($top_click_count>=10)?$top_click_count/10:1) );
|
115 |
+
$y->set_colour( '#A2ACBA' );
|
116 |
+
|
117 |
+
$chart = new open_flash_chart();
|
118 |
+
$chart->set_title( $title );
|
119 |
+
$chart->set_bg_colour("-1");
|
120 |
+
$chart->set_y_axis( $y );
|
121 |
+
$chart->add_element( $line );
|
122 |
+
|
123 |
+
$x_labels = new x_axis_labels();
|
124 |
+
$x_labels->set_steps( 2 );
|
125 |
+
$x_labels->rotate(45);
|
126 |
+
$x_labels->set_colour( '#000000' );
|
127 |
+
$x_labels->set_labels( array_keys($data_array) );
|
128 |
+
|
129 |
+
$x = new x_axis();
|
130 |
+
$x->set_colour( '#A2ACBA' );
|
131 |
+
$x->set_grid_colour( '#ffefa7' );
|
132 |
+
$x->set_offset( false );
|
133 |
+
$x->set_steps(4);
|
134 |
+
|
135 |
+
// Add the X Axis Labels to the X Axis
|
136 |
+
$x->set_labels( $x_labels );
|
137 |
+
$chart->set_x_axis( $x );
|
138 |
+
|
139 |
+
return $chart->toPrettyString();
|
140 |
+
*/
|
141 |
+
}
|
142 |
+
|
143 |
+
// Detects whether an array is a true numerical array or an
|
144 |
+
// associative array (or hash).
|
145 |
+
function prli_array_type($item)
|
146 |
+
{
|
147 |
+
$array_type = 'unknown';
|
148 |
+
|
149 |
+
if(is_array($item))
|
150 |
+
{
|
151 |
+
$array_type = 'array';
|
152 |
+
|
153 |
+
foreach($item as $key => $value)
|
154 |
+
{
|
155 |
+
if(!is_numeric($key))
|
156 |
+
{
|
157 |
+
$array_type = 'hash';
|
158 |
+
break;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
return $array_type;
|
164 |
+
}
|
165 |
+
|
166 |
+
// This eliminates the need to use php's built in json_encoder
|
167 |
+
// which only works with PHP 5.2 and above.
|
168 |
+
function prli_json_encode($json_array)
|
169 |
+
{
|
170 |
+
$json_str = '';
|
171 |
+
|
172 |
+
if(is_array($json_array))
|
173 |
+
{
|
174 |
+
if($this->prli_array_type($json_array) == 'array')
|
175 |
+
{
|
176 |
+
$first = true;
|
177 |
+
$json_str .= "[";
|
178 |
+
foreach($json_array as $item)
|
179 |
+
{
|
180 |
+
if(!$first)
|
181 |
+
$json_str .= ",";
|
182 |
+
|
183 |
+
if(is_numeric($item))
|
184 |
+
$json_str .= (($item < 0)?"\"$item\"":$item);
|
185 |
+
else if(is_array($item))
|
186 |
+
$json_str .= $this->prli_json_encode($item);
|
187 |
+
else if(is_string($item))
|
188 |
+
$json_str .= '"'.$item.'"';
|
189 |
+
else if(is_bool($item))
|
190 |
+
$json_str .= (($item)?"true":"false");
|
191 |
+
|
192 |
+
$first = false;
|
193 |
+
}
|
194 |
+
$json_str .= "]";
|
195 |
+
}
|
196 |
+
else if($this->prli_array_type($json_array) == 'hash')
|
197 |
+
{
|
198 |
+
$first = true;
|
199 |
+
$json_str .= "{";
|
200 |
+
foreach($json_array as $key => $item)
|
201 |
+
{
|
202 |
+
if(!$first)
|
203 |
+
$json_str .= ",";
|
204 |
+
|
205 |
+
$json_str .= "\"$key\":";
|
206 |
+
|
207 |
+
if(is_numeric($item))
|
208 |
+
$json_str .= (($item < 0)?"\"$item\"":$item);
|
209 |
+
else if(is_array($item))
|
210 |
+
$json_str .= $this->prli_json_encode($item);
|
211 |
+
else if(is_string($item))
|
212 |
+
$json_str .= "\"$item\"";
|
213 |
+
else if(is_bool($item))
|
214 |
+
$json_str .= (($item)?"true":"false");
|
215 |
+
|
216 |
+
$first = false;
|
217 |
+
}
|
218 |
+
$json_str .= "}";
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
return $json_str;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
?>
|
classes/models/PrliUtils.php
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'models.inc.php';
|
3 |
+
|
4 |
+
class PrliUtils
|
5 |
+
{
|
6 |
+
|
7 |
+
/** Okay I realize that Percentagize isn't really a word but
|
8 |
+
* this is so that the values we have will work with google
|
9 |
+
* charts.
|
10 |
+
*/
|
11 |
+
function percentagizeArray($data,$max_value)
|
12 |
+
{
|
13 |
+
$new_data = array();
|
14 |
+
foreach($data as $point)
|
15 |
+
{
|
16 |
+
if( $max_value > 0 )
|
17 |
+
{
|
18 |
+
$new_data[] = $point / $max_value * 100;
|
19 |
+
}
|
20 |
+
else
|
21 |
+
{
|
22 |
+
$new_data[] = 0;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
return $new_data;
|
26 |
+
}
|
27 |
+
|
28 |
+
function getTopValue($values_array)
|
29 |
+
{
|
30 |
+
rsort($values_array);
|
31 |
+
return $values_array[0];
|
32 |
+
}
|
33 |
+
|
34 |
+
function getFirstClickDate()
|
35 |
+
{
|
36 |
+
global $wpdb;
|
37 |
+
|
38 |
+
$clicks_table = $wpdb->prefix . "prli_clicks";
|
39 |
+
$query = "SELECT created_at FROM $clicks_table ORDER BY created_at LIMIT 1";
|
40 |
+
$first_click = $wpdb->get_var($query);
|
41 |
+
|
42 |
+
if(isset($first_click))
|
43 |
+
{
|
44 |
+
return strtotime($first_click);
|
45 |
+
}
|
46 |
+
else
|
47 |
+
return null;
|
48 |
+
}
|
49 |
+
|
50 |
+
function getMonthsArray()
|
51 |
+
{
|
52 |
+
global $wpdb;
|
53 |
+
global $prli_click;
|
54 |
+
|
55 |
+
$months = array();
|
56 |
+
$year = date("Y");
|
57 |
+
$month = date("m");
|
58 |
+
$current_timestamp = time();
|
59 |
+
$current_month_timestamp = mktime(0, 0, 0, date("m", $current_timestamp), 1, date("Y", $current_timestamp));
|
60 |
+
|
61 |
+
$clicks_table = $prli_click->tableName();
|
62 |
+
$first_click = $wpdb->get_var("SELECT created_at FROM $clicks_table ORDER BY created_at LIMIT 1;");
|
63 |
+
$first_timestamp = ((empty($first_click))?$current_timestamp:strtotime($first_click));
|
64 |
+
$first_date = mktime(0, 0, 0, date("m", $first_timestamp), 1, date("Y", $first_timestamp));
|
65 |
+
|
66 |
+
while($current_month_timestamp >= $first_date)
|
67 |
+
{
|
68 |
+
$months[] = $current_month_timestamp;
|
69 |
+
if(date("m") == 1)
|
70 |
+
{
|
71 |
+
$current_month_timestamp = mktime(0, 0, 0, 12, 1, date("Y", $current_month_timestamp)-1);
|
72 |
+
}
|
73 |
+
else
|
74 |
+
{
|
75 |
+
$current_month_timestamp = mktime(0, 0, 0, date("m", $current_month_timestamp)-1, 1, date("Y", $current_month_timestamp));
|
76 |
+
}
|
77 |
+
}
|
78 |
+
return $months;
|
79 |
+
}
|
80 |
+
|
81 |
+
// For Pagination
|
82 |
+
function getLastRecordNum($r_count,$current_p,$p_size)
|
83 |
+
{
|
84 |
+
return (($r_count < ($current_p * $p_size))?$r_count:($current_p * $p_size));
|
85 |
+
}
|
86 |
+
|
87 |
+
// For Pagination
|
88 |
+
function getFirstRecordNum($r_count,$current_p,$p_size)
|
89 |
+
{
|
90 |
+
if($current_p == 1)
|
91 |
+
{
|
92 |
+
return 1;
|
93 |
+
}
|
94 |
+
else
|
95 |
+
{
|
96 |
+
return ($this->getLastRecordNum($r_count,($current_p - 1),$p_size) + 1);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
function slugIsAvailable($slug)
|
101 |
+
{
|
102 |
+
global $wpdb;
|
103 |
+
|
104 |
+
$posts_table = $wpdb->prefix . "posts";
|
105 |
+
$terms_table = $wpdb->prefix . "terms";
|
106 |
+
|
107 |
+
$post_slug = $wpdb->get_var("SELECT post_name FROM $posts_table WHERE post_name='$slug'");
|
108 |
+
$term_slug = $wpdb->get_col("SELECT slug FROM $terms_table WHERE slug='$slug'");
|
109 |
+
|
110 |
+
return ( $post_slug != $slug and $term_slug != $slug );
|
111 |
+
}
|
112 |
+
|
113 |
+
/* Needed because we don't know if the target uesr will have a browsercap file installed
|
114 |
+
on their server ... particularly in a shared hosting environment this is difficult
|
115 |
+
*/
|
116 |
+
function php_get_browser($agent = NULL)
|
117 |
+
{
|
118 |
+
$agent=$agent?$agent:$_SERVER['HTTP_USER_AGENT'];
|
119 |
+
$yu=array();
|
120 |
+
$q_s=array("#\.#","#\*#","#\?#");
|
121 |
+
$q_r=array("\.",".*",".?");
|
122 |
+
$brows=parse_ini_file(PRLI_PATH."/includes/php/php_browsecap.ini",true);
|
123 |
+
foreach($brows as $k=>$t)
|
124 |
+
{
|
125 |
+
if(fnmatch($k,$agent))
|
126 |
+
{
|
127 |
+
$yu['browser_name_pattern']=$k;
|
128 |
+
$pat=preg_replace($q_s,$q_r,$k);
|
129 |
+
$yu['browser_name_regex']=strtolower("^$pat$");
|
130 |
+
foreach($brows as $g=>$r)
|
131 |
+
{
|
132 |
+
if($t['Parent']==$g)
|
133 |
+
{
|
134 |
+
foreach($brows as $a=>$b)
|
135 |
+
{
|
136 |
+
if($r['Parent']==$a)
|
137 |
+
{
|
138 |
+
$yu=array_merge($yu,$b,$r,$t);
|
139 |
+
foreach($yu as $d=>$z)
|
140 |
+
{
|
141 |
+
$l=strtolower($d);
|
142 |
+
$hu[$l]=$z;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
break;
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
return $hu;
|
154 |
+
}
|
155 |
+
|
156 |
+
// This is where the magic happens!
|
157 |
+
function track_link($slug,$values)
|
158 |
+
{
|
159 |
+
global $wpdb, $prli_click, $prli_link;
|
160 |
+
|
161 |
+
$query = "SELECT * FROM ".$prli_link->table_name()." WHERE slug='$slug' LIMIT 1";
|
162 |
+
$pretty_link = $wpdb->get_row($query);
|
163 |
+
|
164 |
+
$first_click = false;
|
165 |
+
|
166 |
+
$click_ip = $_SERVER['REMOTE_ADDR'];
|
167 |
+
$click_referer = $_SERVER['HTTP_REFERER'];
|
168 |
+
$click_host = gethostbyaddr($click_ip);
|
169 |
+
|
170 |
+
$click_uri = $_SERVER['REQUEST_URI'];
|
171 |
+
$click_user_agent = $_SERVER['HTTP_USER_AGENT'];
|
172 |
+
$click_browser = $this->php_get_browser();
|
173 |
+
|
174 |
+
//Set Cookie if it doesn't exist
|
175 |
+
$cookie_name = 'prli_click_' . $pretty_link->id;
|
176 |
+
//Used for unique click tracking
|
177 |
+
$cookie_expire_time = time()+60*60*24*30; // Expire in 30 days
|
178 |
+
|
179 |
+
$visitor_cookie = 'prli_visitor';
|
180 |
+
//Used for visitor activity
|
181 |
+
$visitor_cookie_expire_time = time()+60*60*24*365; // Expire in 1 year
|
182 |
+
|
183 |
+
|
184 |
+
if($_COOKIE[$cookie_name] == null)
|
185 |
+
{
|
186 |
+
setcookie($cookie_name,$slug,$cookie_expire_time);
|
187 |
+
$first_click = true;
|
188 |
+
}
|
189 |
+
|
190 |
+
// Retrieve / Generate visitor id
|
191 |
+
if($_COOKIE[$visitor_cookie] == null)
|
192 |
+
{
|
193 |
+
$visitor_uid = $prli_click->generateUniqueVisitorId();
|
194 |
+
setcookie($visitor_cookie,$visitor_uid,$visitor_cookie_expire_time);
|
195 |
+
}
|
196 |
+
else
|
197 |
+
$visitor_uid = $_COOKIE[$visitor_cookie];
|
198 |
+
|
199 |
+
//Record Click in DB
|
200 |
+
$insert = "INSERT INTO ".$prli_click->table_name()." (link_id,vuid,ip,browser,btype,bversion,os,referer,uri,host,first_click,created_at) VALUES ($pretty_link->id,'$visitor_uid','$click_ip','$click_user_agent','".$click_browser['browser']."','".$click_browser['version']."','".$click_browser['platform']."','$click_referer','$click_uri','$click_host','$first_click',NOW())";
|
201 |
+
|
202 |
+
$results = $wpdb->query( $insert );
|
203 |
+
|
204 |
+
// Reformat Parameters
|
205 |
+
$param_string = '';
|
206 |
+
|
207 |
+
if(isset($pretty_link->param_forwarding) and $pretty_link->param_forwarding and isset($values) and count($values) > 1)
|
208 |
+
{
|
209 |
+
$first_param = true;
|
210 |
+
foreach($values as $key => $value)
|
211 |
+
{
|
212 |
+
// Ignore the 'sprli' parameter
|
213 |
+
if($key != 'sprli')
|
214 |
+
{
|
215 |
+
if($first_param)
|
216 |
+
{
|
217 |
+
$param_string = (preg_match("#\?#", $pretty_link->url)?"&":"?");
|
218 |
+
$first_param = false;
|
219 |
+
}
|
220 |
+
else
|
221 |
+
$param_string .= "&";
|
222 |
+
|
223 |
+
$param_string .= "$key=$value";
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
//Redirect to Product URL
|
229 |
+
if(!isset($pretty_link->track_as_img) or $pretty_link->track_as_img == 0)
|
230 |
+
{
|
231 |
+
wp_redirect($pretty_link->url.$param_string, (int)$pretty_link->redirect_type);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
function get_custom_forwarding_rule($param_struct)
|
236 |
+
{
|
237 |
+
$param_struct = preg_replace('#%.*?%#','(.*?)',$param_struct);
|
238 |
+
return preg_replace('#\(\.\*\?\)$#','(.*)',$param_struct); // replace the last one with a greedy operator
|
239 |
+
}
|
240 |
+
|
241 |
+
function get_custom_forwarding_params($param_struct, $start_index = 1)
|
242 |
+
{
|
243 |
+
preg_match_all('#%(.*?)%#', $param_struct, $matches);
|
244 |
+
|
245 |
+
$param_string = '';
|
246 |
+
$match_index = $start_index;
|
247 |
+
for($i = 0; $i < count($matches[1]); $i++)
|
248 |
+
{
|
249 |
+
if($i == 0 and $start_index == 1)
|
250 |
+
$param_string .= "?";
|
251 |
+
else
|
252 |
+
$param_string .= "&";
|
253 |
+
|
254 |
+
$param_string .= $matches[1][$i] . "=$$match_index";
|
255 |
+
$match_index++;
|
256 |
+
}
|
257 |
+
|
258 |
+
return $param_string;
|
259 |
+
}
|
260 |
+
|
261 |
+
function decode_custom_param_str($param_struct, $uri_string)
|
262 |
+
{
|
263 |
+
// Get the structure matches (param names)
|
264 |
+
preg_match_all('#%(.*?)%#', $param_struct, $struct_matches);
|
265 |
+
|
266 |
+
// Get the uri matches (param values)
|
267 |
+
$match_str = '#'.$this->get_custom_forwarding_rule($param_struct).'#';
|
268 |
+
preg_match($match_str, $uri_string, $uri_matches);
|
269 |
+
|
270 |
+
$param_array = array();
|
271 |
+
for($i = 0; $i < count($struct_matches[1]); $i++)
|
272 |
+
$param_array[$struct_matches[1][$i]] = $uri_matches[$i+1];
|
273 |
+
|
274 |
+
return $param_array;
|
275 |
+
}
|
276 |
+
|
277 |
+
}
|
278 |
+
?>
|
classes/models/models.inc.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once(PRLI_MODELS_PATH.'/PrliLink.php');
|
3 |
+
require_once(PRLI_MODELS_PATH.'/PrliClick.php');
|
4 |
+
require_once(PRLI_MODELS_PATH.'/PrliReport.php');
|
5 |
+
require_once(PRLI_MODELS_PATH.'/PrliUtils.php');
|
6 |
+
|
7 |
+
$prli_link = new PrliLink();
|
8 |
+
$prli_click = new PrliClick();
|
9 |
+
$prli_report = new PrliReport();
|
10 |
+
$prli_utils = new PrliUtils();
|
11 |
+
?>
|
classes/views/prli-clicks/csv.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once('prli-config.php');
|
3 |
+
|
4 |
+
if(is_user_logged_in() and $current_user->user_level >= 8)
|
5 |
+
{
|
6 |
+
$filename = date("ymdHis",time()) . '_' . $link_name . '_pretty_link_clicks.csv';
|
7 |
+
header("Content-Type: text/x-csv");
|
8 |
+
header("Content-Disposition: attachment; filename=\"$filename\"");
|
9 |
+
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
|
10 |
+
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
11 |
+
header("Cache-Control: no-cache, must-revalidate");
|
12 |
+
header("Pragma: no-cache");
|
13 |
+
|
14 |
+
echo '"Browser","Browser Version","Platform","IP","Visitor ID","Timestamp","Host","URI","Referrer","Link"' . "\n";
|
15 |
+
foreach($clicks as $click)
|
16 |
+
{
|
17 |
+
$link = $prli_link->getOne($click->link_id);
|
18 |
+
|
19 |
+
echo "\"$click->btype\",\"$click->bversion\",\"$click->os\",\"$click->ip\",\"$click->vuid\",\"$click->created_at\",\"$click->host\",\"$click->uri\",\"$click->referer\",\"" . ((empty($link->name))?$link->slug:$link->name) . "\"\n";
|
20 |
+
}
|
21 |
+
}
|
22 |
+
else
|
23 |
+
header("Location: " . $prli_blogurl);
|
24 |
+
?>
|
classes/views/prli-clicks/list.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<p style="font-size: 14px; font-weight: bold; float: right; padding-top: 25px;"><a href="http://blairwilliams.com/faq" target="_blank">Get Help</a> | <a href="http://blairwilliams.com/blog" target="_blank">Blog</a> | <a href="http://blairwilliams.com/don" target="_blank">Donate</a></p>
|
3 |
+
<h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/> Pretty Link: Hits</h2>
|
4 |
+
<br/>
|
5 |
+
<div id="search_pane" style="float: right;">
|
6 |
+
<form class="form-fields" name="click_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
|
7 |
+
<?php wp_nonce_field('prli-clicks'); ?>
|
8 |
+
|
9 |
+
<input type="hidden" name="sort" id="sort" value="<?php echo $sort_str; ?>" />
|
10 |
+
<input type="hidden" name="sdir" id="sort" value="<?php echo $sdir_str; ?>" />
|
11 |
+
<input type="text" name="search" id="search" value="<?php echo $search_str; ?>" style="display:inline;"/>
|
12 |
+
<div class="submit" style="display: inline;"><input type="submit" name="Submit" value="Search"/>
|
13 |
+
<?php
|
14 |
+
if(!empty($search_str))
|
15 |
+
{
|
16 |
+
?>
|
17 |
+
or <a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php<?php echo (isset($_GET['l'])?'&l='.$_GET['l']:''); ?>">Reset</a>
|
18 |
+
<?php
|
19 |
+
}
|
20 |
+
?>
|
21 |
+
</div>
|
22 |
+
</form>
|
23 |
+
</div>
|
24 |
+
<h3>For <?php echo $link_name; ?></h3>
|
25 |
+
|
26 |
+
<?php
|
27 |
+
if(isset($_GET['l']))
|
28 |
+
echo '<a href="?page='. PRLI_PLUGIN_NAME .'/prli-links.php">« Back to Links</a>';
|
29 |
+
else if(isset($_GET['ip']) or isset($_GET['vuid']))
|
30 |
+
echo '<a href="?page='. PRLI_PLUGIN_NAME .'/prli-clicks.php">« Back to Hits</a>';
|
31 |
+
|
32 |
+
require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
|
33 |
+
?>
|
34 |
+
|
35 |
+
<table class="widefat post fixed" cellspacing="0">
|
36 |
+
<thead>
|
37 |
+
<tr>
|
38 |
+
<th class="manage-column" width="5%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=btype<?php echo (($sort_str == 'btype' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Browser<?php echo (($sort_str == 'btype')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
39 |
+
<th class="manage-column" width="12%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=ip<?php echo (($sort_str == 'ip' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">IP<?php echo (($sort_str == 'ip')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
40 |
+
<th class="manage-column" width="12%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=vuid<?php echo (($sort_str == 'vuid' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Visitor<?php echo (($sort_str == 'vuid')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
41 |
+
<th class="manage-column" width="13%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=created_at<?php echo (($sort_str == 'created_at' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Timestamp<?php echo ((empty($sort_str) or $sort_str == 'created_at')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.((empty($sort_str) or $sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
42 |
+
<th class="manage-column" width="16%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=host<?php echo (($sort_str == 'host' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Host<?php echo (($sort_str == 'host')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
43 |
+
<th class="manage-column" width="16%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=uri<?php echo (($sort_str == 'uri' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">URI<?php echo (($sort_str == 'uri')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
44 |
+
<th class="manage-column" width="16%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=referer<?php echo (($sort_str == 'referer' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Referrer<?php echo (($sort_str == 'referer')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
45 |
+
<th class="manage-column" width="13%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&sort=link<?php echo (($sort_str == 'link' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Link<?php echo (($sort_str == 'link')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
46 |
+
</tr>
|
47 |
+
</thead>
|
48 |
+
<?php
|
49 |
+
|
50 |
+
if(count($clicks) <= 0)
|
51 |
+
{
|
52 |
+
?>
|
53 |
+
<tr>
|
54 |
+
<td colspan="7">No Hits have been recorded yet</td>
|
55 |
+
</tr>
|
56 |
+
<?php
|
57 |
+
}
|
58 |
+
else
|
59 |
+
{
|
60 |
+
foreach($clicks as $click)
|
61 |
+
{
|
62 |
+
?>
|
63 |
+
<tr>
|
64 |
+
<td><img src="<?php echo $prli_siteurl; ?>/wp-content/plugins/<?php echo PRLI_PLUGIN_NAME; ?>/images/browser/<?php echo prli_browser_image($click->btype); ?>" alt="<?php echo $click->btype . " v" . $click->bversion; ?>" title="<?php echo $click->btype . " v" . $click->bversion; ?>"/> <img src="<?php echo $prli_siteurl; ?>/wp-content/plugins/<?php echo PRLI_PLUGIN_NAME; ?>/images/os/<?php echo prli_os_image($click->os); ?>" alt="<?php echo $click->os; ?>" title="<?php echo $click->os; ?>"/></td>
|
65 |
+
<td><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&ip=<?php echo $click->ip; ?>" title="View All Activity for IP Address: <?php echo $click->ip; ?>"><?php echo $click->ip; ?></a></td>
|
66 |
+
<td><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php&vuid=<?php echo $click->vuid; ?>" title="View All Activity for Visitor: <?php echo $click->vuid; ?>"><?php echo $click->vuid; ?></a></td>
|
67 |
+
<td><?php echo $click->created_at; ?></td>
|
68 |
+
<td><?php echo $click->host; ?></td>
|
69 |
+
<td><?php echo $click->uri; ?></td>
|
70 |
+
<td><?php echo $click->referer; ?></td>
|
71 |
+
<td><?php echo $click->link_name; ?></td>
|
72 |
+
</tr>
|
73 |
+
<?php
|
74 |
+
}
|
75 |
+
}
|
76 |
+
?>
|
77 |
+
<tfoot>
|
78 |
+
<tr>
|
79 |
+
<th class="manage-column">Browser</th>
|
80 |
+
<th class="manage-column">IP</th>
|
81 |
+
<th class="manage-column">Visitor</th>
|
82 |
+
<th class="manage-column">Timestamp</th>
|
83 |
+
<th class="manage-column">Host</th>
|
84 |
+
<th class="manage-column">URI</th>
|
85 |
+
<th class="manage-column">Referrer</th>
|
86 |
+
<th class="manage-column">Link</th>
|
87 |
+
</tr>
|
88 |
+
</tfoot>
|
89 |
+
</table>
|
90 |
+
<?php
|
91 |
+
if(isset($_GET['l']))
|
92 |
+
{
|
93 |
+
?>
|
94 |
+
<a href="<?php echo $prli_siteurl; ?>/wp-content/plugins/<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php?action=csv&l=<?php echo $_GET['l']; ?>">Download CSV (<?php echo $link_name; ?>)</a>
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
else
|
98 |
+
{
|
99 |
+
?>
|
100 |
+
<a href="<?php echo $prli_siteurl; ?>/wp-content/plugins/<?php echo PRLI_PLUGIN_NAME; ?>/prli-clicks.php?action=csv">Download CSV (<?php echo $link_name; ?>)</a>
|
101 |
+
<?php
|
102 |
+
}
|
103 |
+
require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
|
104 |
+
?>
|
105 |
+
|
106 |
+
</div>
|
classes/views/prli-links/edit.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/> Pretty Link: Edit Link</h2>
|
3 |
+
|
4 |
+
<?php
|
5 |
+
require(PRLI_VIEWS_PATH.'/shared/errors.php');
|
6 |
+
?>
|
7 |
+
|
8 |
+
<form name="form1" method="post" action="?page=<?php print PRLI_PLUGIN_NAME ?>/prli-links.php">
|
9 |
+
<input type="hidden" name="action" value="update">
|
10 |
+
<input type="hidden" name="id" value="<?php print $id; ?>">
|
11 |
+
<?php wp_nonce_field('update-options'); ?>
|
12 |
+
|
13 |
+
<table class="form-table">
|
14 |
+
<tr class="form-field">
|
15 |
+
<td width="75px" valign="top">Target URL*: </td>
|
16 |
+
<td><input type="text" name="url" value="<?php print (($_POST['url'] != null and $record == null)?$_POST['url']:$record->url); ?>" size="75">
|
17 |
+
<br/><span class="setting-description">Enter the URL you want to mask and track. Don't forget to start your url with <code>http://</code> or <code>https://</code>. Example: <code>http://www.yoururl.com</code></span></td>
|
18 |
+
</tr>
|
19 |
+
<tr>
|
20 |
+
<td valign="top">Pretty Link*: </td>
|
21 |
+
<td><strong><?php print $prli_blogurl; ?></strong>/<input type="text" name="slug" value="<?php print (($_POST['slug'] != null and $record == null)?$_POST['slug']:$record->slug); ?>" size="25">
|
22 |
+
<br/><span class="setting-description">Enter the slug (word trailing your main URL) that will form your pretty link and redirect to the URL above.</span></td>
|
23 |
+
</tr>
|
24 |
+
<tr class="form-field">
|
25 |
+
<td width="75px" valign="top">Title: </td>
|
26 |
+
<td><input type="text" name="name" value="<?php print (($_POST['name'] != null and $record == null)?$_POST['name']:$record->name); ?>" size="75">
|
27 |
+
<br/><span class="setting-description">This will act as the title of your Pretty Link. If a name is not entered here then the slug name will be used.</span></td>
|
28 |
+
</tr>
|
29 |
+
<tr class="form-field">
|
30 |
+
<td valign="top">Description: </td>
|
31 |
+
<td><textarea style="height: 100px;" name="description"><?php print (($_POST['description'] != null and $record == null)?$_POST['description']:$record->description); ?></textarea>
|
32 |
+
<br/><span class="setting-description">A Description of this link.</span></td>
|
33 |
+
</tr>
|
34 |
+
</table>
|
35 |
+
<a href="#" class="advanced_toggle">Advanced Options</a>
|
36 |
+
<div class="advanced_pane">
|
37 |
+
<table class="form-table">
|
38 |
+
<tr>
|
39 |
+
<td colspan="2">
|
40 |
+
<h3>Parameter Forwarding</h3>
|
41 |
+
<ul style="list-style-type: none">
|
42 |
+
<li>
|
43 |
+
<input type="radio" name="param_forwarding" value="off" <?php print ((!isset($_POST['param_forwarding']) or $record->param_forwarding == 'off')?'checked="true"':''); ?>/> Forward Parameters Off
|
44 |
+
<br/><span class="setting-description">You may want to leave this option off if you don't need to forward any parameters on to your Target URL.</span>
|
45 |
+
</li>
|
46 |
+
<li>
|
47 |
+
<input type="radio" name="param_forwarding" value="on" <?php print (((isset($_POST['param_forwarding']) and $_POST['param_forwarding'] == 'on') or (isset($record->param_forwarding) and $record->param_forwarding == 'on'))?'checked="true"':''); ?> /> Standard Parameter Forwarding
|
48 |
+
<br/><span class="setting-description">Select this option if you want to forward parameters through your pretty link to your Target URL. This will allow you to pass parameters in the standard syntax for example the pretty link <code>http://yoururl.com/coollink?product_id=4&sku=5441</code> will forward to the target URL and append the same parameters like so: <code>http://anotherurl.com?product_id=4&sku=5441</code>.</span>
|
49 |
+
</li>
|
50 |
+
<li>
|
51 |
+
<input type="radio" name="param_forwarding" value="custom" <?php print (((isset($_POST['param_forwarding']) and $_POST['param_forwarding'] == 'custom') or (isset($record->param_forwarding) and $record->param_forwarding == 'custom'))?'checked="true"':''); ?> /> Custom Parameter Forwarding <input type="text" name="param_struct" value="<?php print (($_POST['param_struct'] != null and $record == null)?$_POST['param_struct']:$record->param_struct); ?>" size="25"/>
|
52 |
+
<br/><span class="setting-description">Select this option if you want to forward parameters through your Pretty Link to your Target URL and write the parameters in a custom format. For example, say I wanted to to have my links look like this: <code>http://yourdomain.com/products/14/4</code> and I wanted this to forward to <code>http://anotherurl.com?product_id=14&dock=4</code> you'd just select this option and enter the following string into the text field <code>/products/%product_id%/%dock%</code>. This will tell Pretty Link where each variable will be located in the URL and what each variable name is.</span>
|
53 |
+
</li>
|
54 |
+
</ul>
|
55 |
+
</td>
|
56 |
+
</tr>
|
57 |
+
<tr>
|
58 |
+
<td colspan="2">
|
59 |
+
<h3>Redirect Type</h3>
|
60 |
+
<ul style="list-style-type: none">
|
61 |
+
<li>
|
62 |
+
<input type="radio" name="redirect_type" value="307" <?php print ((!isset($_POST['redirect_type']) or $_POST['redirect_type'] == '307' or $record->redirect_type == '307')?'checked="true"':''); ?>/> Temporary Redirect (307)
|
63 |
+
<br/><span class="setting-description">This is the best option if you're planning on changing your Target URL and want accurate reporting for this link.</span>
|
64 |
+
</li>
|
65 |
+
<li>
|
66 |
+
<input type="radio" name="redirect_type" value="301" <?php print (((isset($_POST['redirect_type']) and $_POST['redirect_type'] == '301') or (isset($record->redirect_type) and $record->redirect_type == '301'))?'checked="true"':''); ?> /> Permanent Redirect (301)
|
67 |
+
<br/><span class="setting-description">This is the best option if you're <strong>NOT</strong> planning on changing your Target URL. Traditionally this option is considered to be the best approach to use for your SEO/SEM efforts but since Pretty Link uses your domain name either way this notion isn't necessarily true for Pretty Links. Also, this option may not give you accurate reporting since proxy and caching servers may go directly to your Target URL once it's cached.</span>
|
68 |
+
</li>
|
69 |
+
</ul>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<tr>
|
73 |
+
<td colspan="2">
|
74 |
+
<h3>Pixel Tracking</h3>
|
75 |
+
<input type="checkbox" name="track_as_img" <?php print ((($_POST['track_as_img'] or $record->track_as_img) and ($_POST['track_as_img'] == 'on' or $record->track_as_img == 1))?'checked="true"':''); ?>/> Track as a Pixel
|
76 |
+
<br/><span class="setting-description">Select this option if you want this link to behave as a tracking pixel instead of as a link. This option is useful if you want to track the number of times a page or email is opened. If you place your Pretty Link inside an img tag on the page (Example: <code><img src="<?php echo $prli_blogurl . "/yourslug"; ?>" /></code>) then the page load will be tracked as a click and then displayed. Note: If this option is selected your Target URL will simply be ignored if there's a value in it.</span>
|
77 |
+
</td>
|
78 |
+
</tr>
|
79 |
+
</table>
|
80 |
+
</div>
|
81 |
+
|
82 |
+
<p class="submit">
|
83 |
+
<input type="submit" name="Submit" value="Update" /> or <a href="?page=<?php print PRLI_PLUGIN_NAME ?>/prli-links.php">Cancel</a>
|
84 |
+
</p>
|
85 |
+
|
86 |
+
</form>
|
87 |
+
</div>
|
classes/views/prli-links/list.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<p style="font-size: 14px; font-weight: bold; float: right; padding-top: 25px;"><a href="http://blairwilliams.com/faq" target="_blank">Get Help</a> | <a href="http://blairwilliams.com/blog" target="_blank">Blog</a> | <a href="http://blairwilliams.com/don" target="_blank">Donate</a></p>
|
3 |
+
<h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/> Pretty Link: Links</h2>
|
4 |
+
<div id="message" class="updated fade" style="padding:5px;"><?php echo $prli_message; ?></div>
|
5 |
+
<div id="search_pane" style="float: right;">
|
6 |
+
<form class="form-fields" name="link_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
|
7 |
+
<?php wp_nonce_field('prli-links'); ?>
|
8 |
+
<input type="hidden" name="sort" id="sort" value="<?php echo $sort_str; ?>" />
|
9 |
+
<input type="hidden" name="sdir" id="sort" value="<?php echo $sdir_str; ?>" />
|
10 |
+
<input type="text" name="search" id="search" value="<?php echo $search_str; ?>" style="display:inline;"/>
|
11 |
+
<div class="submit" style="display: inline;"><input type="submit" name="Submit" value="Search"/>
|
12 |
+
<?php
|
13 |
+
if(!empty($search_str))
|
14 |
+
{
|
15 |
+
?>
|
16 |
+
or <a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-links.php">Reset</a>
|
17 |
+
<?php
|
18 |
+
}
|
19 |
+
?>
|
20 |
+
</div>
|
21 |
+
</form>
|
22 |
+
</div>
|
23 |
+
<div id="button_bar">
|
24 |
+
<p><a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php&action=new"><img src="<?php echo PRLI_URL.'/images/pretty-link-add.png'; ?>"/> Add a Pretty Link</a>
|
25 |
+
| <a href="options-general.php?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-options.php">Options</a>
|
26 |
+
<?php
|
27 |
+
if(get_option('prli_rewrite_mode') == 'on')
|
28 |
+
{
|
29 |
+
?>
|
30 |
+
| <a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php®enerate=true">Manually Regenerate Pretty Links</a>
|
31 |
+
<?php
|
32 |
+
}
|
33 |
+
?>
|
34 |
+
</p>
|
35 |
+
</div>
|
36 |
+
|
37 |
+
<?php
|
38 |
+
require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
|
39 |
+
?>
|
40 |
+
<table class="widefat post fixed" cellspacing="0">
|
41 |
+
<thead>
|
42 |
+
<tr>
|
43 |
+
<th class="manage-column" width="45%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-links.php&sort=name<?php echo (($sort_str == 'name' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Name<?php echo (($sort_str == 'name')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
44 |
+
<th class="manage-column" width="7%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-links.php&sort=clicks<?php echo (($sort_str == 'clicks' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Hits<?php echo (($sort_str == 'clicks')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
45 |
+
<th class="manage-column" width="5%">Redirect</a></th>
|
46 |
+
<th class="manage-column" width="13%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-links.php&sort=created_at<?php echo (($sort_str == 'created_at' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Created<?php echo ((empty($sort_str) or $sort_str == 'created_at')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.((empty($sort_str) or $sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
47 |
+
<th class="manage-column" width="30%"><a href="?page=<?php echo PRLI_PLUGIN_NAME; ?>/prli-links.php&sort=slug<?php echo (($sort_str == 'slug' and $sdir_str == 'asc')?'&sdir=desc':''); ?>">Links<?php echo (($sort_str == 'slug')?' <img src="'.$prli_siteurl.'/wp-content/plugins/'.PRLI_PLUGIN_NAME.'/images/'.(($sdir_str == 'desc')?'arrow_down.png':'arrow_up.png').'"/>':'') ?></a></th>
|
48 |
+
</tr>
|
49 |
+
</thead>
|
50 |
+
<?php
|
51 |
+
|
52 |
+
if($record_count <= 0)
|
53 |
+
{
|
54 |
+
?>
|
55 |
+
<tr>
|
56 |
+
<td colspan="5">No Pretty Links were found</td>
|
57 |
+
</tr>
|
58 |
+
<?php
|
59 |
+
}
|
60 |
+
else
|
61 |
+
{
|
62 |
+
foreach($links as $link)
|
63 |
+
{
|
64 |
+
$pretty_link_url = $prli_link->get_pretty_link_url($link->slug);//$prli_blogurl . '/' . $link->slug;
|
65 |
+
?>
|
66 |
+
<tr>
|
67 |
+
<td class="edit_link">
|
68 |
+
<?php |