Version Description
Download this release
Release Info
Developer | supercleanse |
Plugin | Shortlinks by Pretty Links – Best WordPress Link Tracking Plugin |
Version | 1.3.4 |
Comparing to | |
See all releases |
Version 1.3.4
- classes/models/PrliClick.php +116 -0
- classes/models/PrliLink.php +212 -0
- classes/models/PrliReport.php +226 -0
- classes/models/PrliUtils.php +262 -0
- classes/models/models.inc.php +11 -0
- classes/views/prli-clicks/csv.php +24 -0
- classes/views/prli-clicks/list.php +80 -0
- classes/views/prli-links/edit.php +70 -0
- classes/views/prli-links/list.php +142 -0
- classes/views/prli-links/new.php +70 -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 +469 -0
- prli-clicks.php +67 -0
- prli-config.php +13 -0
- prli-image-lookups.php +136 -0
- prli-links.php +233 -0
- prli-options.php +81 -0
- prli-reports.php +9 -0
- prli.php +18 -0
- readme.txt +74 -0
classes/models/PrliClick.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliClick
|
3 |
+
{
|
4 |
+
function table_name()
|
5 |
+
{
|
6 |
+
global $wpdb;
|
7 |
+
return $wpdb->prefix . 'prli_clicks';
|
8 |
+
}
|
9 |
+
|
10 |
+
/*
|
11 |
+
function create( $values )
|
12 |
+
{
|
13 |
+
global $wpdb, $wp_rewrite;
|
14 |
+
$query = 'INSERT INTO ' . $this->table_name() .
|
15 |
+
' (url,slug,forward_params,track_as_img,created_at) VALUES (\'' .
|
16 |
+
$values['url'] . '\',\'' .
|
17 |
+
$values['slug'] . '\',' .
|
18 |
+
(int)isset($values['forward_params']) . ',' .
|
19 |
+
(int)isset($values['track_as_img']) . ',' .
|
20 |
+
'NOW())';
|
21 |
+
$query_results = $wpdb->query($query);
|
22 |
+
$wp_rewrite->flush_rules();
|
23 |
+
return $query_results;
|
24 |
+
}
|
25 |
+
|
26 |
+
function update( $id, $values )
|
27 |
+
{
|
28 |
+
global $wpdb, $wp_rewrite;
|
29 |
+
$query = 'UPDATE ' . $this->table_name() .
|
30 |
+
' SET url=\'' . $values['url'] . '\', ' .
|
31 |
+
' slug=\'' . $values['slug'] . '\', ' .
|
32 |
+
' forward_params=' . (int)isset($values['forward_params']) . ', ' .
|
33 |
+
' track_as_img=' . (int)isset($values['track_as_img']) .
|
34 |
+
' WHERE id='.$id;
|
35 |
+
$query_results = $wpdb->query($query);
|
36 |
+
$wp_rewrite->flush_rules();
|
37 |
+
return $query_results;
|
38 |
+
}
|
39 |
+
|
40 |
+
function destroy( $id )
|
41 |
+
{
|
42 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
43 |
+
global $wpdb, $wp_rewrite;
|
44 |
+
$destroy = 'DELETE FROM ' . $this->table_name() . ' WHERE id=' . $id;
|
45 |
+
$wp_rewrite->flush_rules();
|
46 |
+
return $wpdb->query($destroy);
|
47 |
+
}
|
48 |
+
*/
|
49 |
+
|
50 |
+
function get_ip_exclude_list()
|
51 |
+
{
|
52 |
+
$exclude_list = get_option('prli_exclude_ips');
|
53 |
+
$exclude_list = preg_replace('#[ \t]#','',$exclude_list);
|
54 |
+
|
55 |
+
if($exclude_list)
|
56 |
+
return "'" . implode("','", explode(',',$exclude_list)) . "'";
|
57 |
+
else
|
58 |
+
return '';
|
59 |
+
}
|
60 |
+
|
61 |
+
function get_exclude_where_clause( $starts_with = " WHERE")
|
62 |
+
{
|
63 |
+
$exclude_list = $this->get_ip_exclude_list();
|
64 |
+
|
65 |
+
if( $exclude_list != '')
|
66 |
+
return $starts_with . ' ip NOT IN (' . $exclude_list . ')';
|
67 |
+
else
|
68 |
+
return '';
|
69 |
+
}
|
70 |
+
|
71 |
+
function getOne( $id )
|
72 |
+
{
|
73 |
+
global $wpdb;
|
74 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
75 |
+
$query = 'SELECT * FROM ' . $this->table_name() . ' li WHERE id=' . $id . $this->get_exclude_where_clause( ' AND' );
|
76 |
+
|
77 |
+
return $wpdb->get_row($query);
|
78 |
+
}
|
79 |
+
|
80 |
+
function getAll($where = "")
|
81 |
+
{
|
82 |
+
global $wpdb;
|
83 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
84 |
+
$where .= $this->get_exclude_where_clause( (($where != '')?' AND':' WHERE') );
|
85 |
+
$query = 'SELECT * FROM ' . $this->table_name() . $where . " ORDER BY created_at DESC";
|
86 |
+
return $wpdb->get_results($query);
|
87 |
+
}
|
88 |
+
|
89 |
+
// Pagination Methods
|
90 |
+
function getRecordCount($where="")
|
91 |
+
{
|
92 |
+
global $wpdb;
|
93 |
+
$where .= $this->get_exclude_where_clause( (($where != '')?' AND':' WHERE') );
|
94 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name() . $where;
|
95 |
+
return $wpdb->get_var($query);
|
96 |
+
}
|
97 |
+
|
98 |
+
function getPageCount($p_size, $where="")
|
99 |
+
{
|
100 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
101 |
+
}
|
102 |
+
|
103 |
+
function getPage($current_p,$p_size, $where = "")
|
104 |
+
{
|
105 |
+
global $wpdb;
|
106 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
107 |
+
$end_index = $current_p * $p_size;
|
108 |
+
$start_index = $end_index - $p_size;
|
109 |
+
$where .= $this->get_exclude_where_clause( (($where != '')?' AND':' WHERE') );
|
110 |
+
$query = 'SELECT * FROM ' . $this->table_name() . $where . ' ORDER BY created_at DESC LIMIT ' . $start_index . ',' . $p_size . ';';
|
111 |
+
$results = $wpdb->get_results($query);
|
112 |
+
return $results;
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
?>
|
classes/models/PrliLink.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,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 |
+
stripslashes($values['description']) . '\',' .
|
23 |
+
(int)isset($values['track_as_img']) . ',' .
|
24 |
+
'NOW())';
|
25 |
+
$query_results = $wpdb->query($query);
|
26 |
+
$wp_rewrite->flush_rules();
|
27 |
+
return $query_results;
|
28 |
+
}
|
29 |
+
|
30 |
+
function update( $id, $values )
|
31 |
+
{
|
32 |
+
global $wpdb, $wp_rewrite;
|
33 |
+
|
34 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$values['slug']);
|
35 |
+
$query = 'UPDATE ' . $this->table_name() .
|
36 |
+
' SET url=\'' . $values['url'] . '\', ' .
|
37 |
+
' slug=\'' . $values['slug'] . '\', ' .
|
38 |
+
' name=\'' . $values['name'] . '\', ' .
|
39 |
+
' param_forwarding=\'' . $values['param_forwarding'] . '\', ' .
|
40 |
+
' param_struct=\'' . $values['param_struct'] . '\', ' .
|
41 |
+
' description=\'' . $values['description'] . '\', ' .
|
42 |
+
' track_as_img=' . (int)isset($values['track_as_img']) .
|
43 |
+
' WHERE id='.$id;
|
44 |
+
$query_results = $wpdb->query($query);
|
45 |
+
$wp_rewrite->flush_rules();
|
46 |
+
return $query_results;
|
47 |
+
}
|
48 |
+
|
49 |
+
function destroy( $id )
|
50 |
+
{
|
51 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
52 |
+
global $wpdb, $prli_click, $wp_rewrite;
|
53 |
+
|
54 |
+
$reset = 'DELETE FROM ' . $prli_click->table_name() . ' WHERE link_id=' . $id;
|
55 |
+
$destroy = 'DELETE FROM ' . $this->table_name() . ' WHERE id=' . $id;
|
56 |
+
|
57 |
+
$wp_rewrite->flush_rules();
|
58 |
+
|
59 |
+
$wpdb->query($reset);
|
60 |
+
return $wpdb->query($destroy);
|
61 |
+
}
|
62 |
+
|
63 |
+
function reset( $id )
|
64 |
+
{
|
65 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
66 |
+
global $wpdb, $wp_rewrite, $prli_click;
|
67 |
+
|
68 |
+
$reset = 'DELETE FROM ' . $prli_click->table_name() . ' WHERE link_id=' . $id;
|
69 |
+
return $wpdb->query($reset);
|
70 |
+
}
|
71 |
+
|
72 |
+
function getOneFromSlug( $slug )
|
73 |
+
{
|
74 |
+
global $wpdb;
|
75 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
76 |
+
$query = 'SELECT * FROM ' . $this->table_name() . ' WHERE slug=\'' . $slug . '\'';
|
77 |
+
return $wpdb->get_row($query);
|
78 |
+
}
|
79 |
+
|
80 |
+
function getOne( $id )
|
81 |
+
{
|
82 |
+
global $wpdb, $prli_click;
|
83 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
84 |
+
$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 . ';';
|
85 |
+
return $wpdb->get_row($query);
|
86 |
+
}
|
87 |
+
|
88 |
+
function getAll()
|
89 |
+
{
|
90 |
+
global $wpdb, $prli_click;
|
91 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
92 |
+
$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;';
|
93 |
+
return $wpdb->get_results($query);
|
94 |
+
}
|
95 |
+
|
96 |
+
// Pagination Methods
|
97 |
+
function getRecordCount($where="")
|
98 |
+
{
|
99 |
+
global $wpdb;
|
100 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name() . $where;
|
101 |
+
return $wpdb->get_var($query);
|
102 |
+
}
|
103 |
+
|
104 |
+
function getPageCount($p_size, $where="")
|
105 |
+
{
|
106 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
107 |
+
}
|
108 |
+
|
109 |
+
function getPage($current_p,$p_size, $where = "")
|
110 |
+
{
|
111 |
+
global $wpdb, $prli_click;
|
112 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
113 |
+
$end_index = $current_p * $p_size;
|
114 |
+
$start_index = $end_index - $p_size;
|
115 |
+
$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 . ';';
|
116 |
+
$results = $wpdb->get_results($query);
|
117 |
+
return $results;
|
118 |
+
}
|
119 |
+
|
120 |
+
/** I'm generating a slug that is by default 2-3 characters long.
|
121 |
+
* This gives us a possibility of 36^3 - 37 = 46,619 possible
|
122 |
+
* random slugs. That should be *more* than enough slugs for
|
123 |
+
* any website -- if I get any feedback that we need more then
|
124 |
+
* I can always make a config option to raise the # of chars.
|
125 |
+
*/
|
126 |
+
function generateValidSlug($num_chars = 3)
|
127 |
+
{
|
128 |
+
global $wpdb, $prli_utils;
|
129 |
+
|
130 |
+
// We're doing a base 36 hash which is why we're always doing everything by 36
|
131 |
+
$max_slug_value = pow(36,$num_chars);
|
132 |
+
$min_slug_value = 37; // we want to have at least 2 characters in the slug
|
133 |
+
$slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
|
134 |
+
|
135 |
+
$query = "SELECT slug FROM " . $this->table_name(); // . " WHERE slug='" . $slug . "'";
|
136 |
+
$slugs = $wpdb->get_col($query,0);
|
137 |
+
|
138 |
+
// It is highly unlikely that we'll ever see 2 identical random slugs
|
139 |
+
// but just in case, here's some code to prevent collisions
|
140 |
+
while( in_array($slug,$slugs) or !$prli_utils->slugIsAvailable($slug) )
|
141 |
+
$slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
|
142 |
+
|
143 |
+
return $slug;
|
144 |
+
}
|
145 |
+
|
146 |
+
function get_pretty_link_url($slug)
|
147 |
+
{
|
148 |
+
global $prli_blogurl;
|
149 |
+
|
150 |
+
$link = $this->getOneFromSlug($slug);
|
151 |
+
|
152 |
+
if((isset($link->param_forwarding) and $link->param_forwarding == 'custom') and
|
153 |
+
(isset($link->track_as_img) and $link->track_as_img == 1))
|
154 |
+
return "<img src=\"".$prli_blogurl . '/' . $link->slug . $link->param_struct . "\" width=\"1\" height=\"1\" style=\"display: none\" />";
|
155 |
+
else if((!isset($link->param_forwarding) or $link->param_forwarding != 'custom') and
|
156 |
+
(isset($link->track_as_img) and $link->track_as_img == 1))
|
157 |
+
return "<img src=\"".$prli_blogurl . '/' . $link->slug . "\" width=\"1\" height=\"1\" style=\"display: none\" />";
|
158 |
+
else if((isset($link->param_forwarding) and $link->param_forwarding == 'custom') and
|
159 |
+
(!isset($link->track_as_img) or $link->track_as_img == 0))
|
160 |
+
return $prli_blogurl . '/' . $link->slug . $link->param_struct;
|
161 |
+
else
|
162 |
+
return $prli_blogurl . '/' . $link->slug;
|
163 |
+
}
|
164 |
+
|
165 |
+
function validate( $values )
|
166 |
+
{
|
167 |
+
global $wpdb, $prli_utils;
|
168 |
+
|
169 |
+
$errors = array();
|
170 |
+
if( ( $values['url'] == null or $values['url'] == '') and $values['track_as_img'] != 'on' )
|
171 |
+
$errors[] = "Target URL can't be blank -- unless this Pretty Link is being used as a tracking pixel (see Advanced Options on this page)";
|
172 |
+
|
173 |
+
if( $values['slug'] == null or $values['slug'] == '' )
|
174 |
+
$errors[] = "Pretty Link can't be blank";
|
175 |
+
|
176 |
+
if( !empty($values['url']) and !preg_match('/^http.?:\/\/.*\..*$/', $values['url'] ) )
|
177 |
+
$errors[] = "Link URL must be a correctly formatted url";
|
178 |
+
|
179 |
+
if( !preg_match('/^[a-zA-Z0-9\.\-_]+$/', $values['slug'] ) )
|
180 |
+
$errors[] = "Pretty Link must not contain spaces or special characters";
|
181 |
+
|
182 |
+
if($values['id'] != null and $values['id'] != '')
|
183 |
+
$query = "SELECT slug FROM " . $this->table_name() . " WHERE slug='" . $values['slug'] . "' AND id <> " . $values['id'];
|
184 |
+
else
|
185 |
+
$query = "SELECT slug FROM " . $this->table_name() . " WHERE slug='" . $values['slug'] . "'";
|
186 |
+
|
187 |
+
$slug_already_exists = $wpdb->get_var($query);
|
188 |
+
|
189 |
+
if( $slug_already_exists or !$prli_utils->slugIsAvailable($values['slug']) )
|
190 |
+
$errors[] = "This pretty link slug is already taken, please choose a different one";
|
191 |
+
|
192 |
+
if( isset($values['param_forwarding']) and $values['param_forwarding'] == 'custom' and empty($values['param_struct']) )
|
193 |
+
$errors[] = "If Custom Parameter Forwarding has been selected then you must specify a forwarding format.";
|
194 |
+
|
195 |
+
if( isset($values['param_forwarding']) and $values['param_forwarding'] == 'custom' and !preg_match('#%.*?%#', $values['param_struct']) )
|
196 |
+
$errors[] = "Your parameter forwarding must have at least one parameter specified in the format ex: <code>/%var1%/%var_two%/%varname3% ...</code>";
|
197 |
+
|
198 |
+
/*
|
199 |
+
if(isset($values['track_as_img']) and $values['track_as_img'] == 'on' and $values['url'] != null and $values['url'] != '')
|
200 |
+
{
|
201 |
+
$size = getimagesize($values['url']);
|
202 |
+
if(!preg_match('#image#',$size['mime']))
|
203 |
+
{
|
204 |
+
$errors[] = "If you want to track this pretty link as an image then your target url must be an image (png, jpeg, gif, etc.)";
|
205 |
+
}
|
206 |
+
}
|
207 |
+
*/
|
208 |
+
|
209 |
+
return $errors;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
?>
|
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 c2 WHERE c2.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,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
function track_link($slug,$values)
|
157 |
+
{
|
158 |
+
global $wpdb;
|
159 |
+
$click_table = $wpdb->prefix . "prli_clicks";
|
160 |
+
$pretty_links_table = $wpdb->prefix . "prli_links";
|
161 |
+
|
162 |
+
$query = "SELECT * FROM $pretty_links_table WHERE slug='$slug' LIMIT 1";
|
163 |
+
$pretty_link = $wpdb->get_row($query);
|
164 |
+
|
165 |
+
$first_click = false;
|
166 |
+
|
167 |
+
$click_ip = $_SERVER['REMOTE_ADDR'];
|
168 |
+
$click_referer = $_SERVER['HTTP_REFERER'];
|
169 |
+
$click_host = gethostbyaddr($click_ip);
|
170 |
+
|
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 |
+
$cookie_expire_time = time()+60*60*24*30; // Expire in 30 days
|
177 |
+
|
178 |
+
if($_COOKIE[$cookie_name] == null)
|
179 |
+
{
|
180 |
+
setcookie($cookie_name,$slug,$cookie_expire_time);
|
181 |
+
$first_click = true;
|
182 |
+
}
|
183 |
+
|
184 |
+
//Record Click in DB
|
185 |
+
$insert = "INSERT INTO $click_table (link_id,ip,browser,btype,bversion,os,referer,host,first_click,created_at) VALUES ($pretty_link->id,'$click_ip','$click_user_agent','".$click_browser['browser']."','".$click_browser['version']."','".$click_browser['platform']."','$click_referer','$click_host','$first_click',NOW())";
|
186 |
+
|
187 |
+
$results = $wpdb->query( $insert );
|
188 |
+
|
189 |
+
$param_string = '';
|
190 |
+
|
191 |
+
if(isset($pretty_link->param_forwarding) and $pretty_link->param_forwarding and isset($values) and count($values) > 1)
|
192 |
+
{
|
193 |
+
$first_param = true;
|
194 |
+
foreach($values as $key => $value)
|
195 |
+
{
|
196 |
+
// Ignore the 'sprli' parameter
|
197 |
+
if($key != 'sprli')
|
198 |
+
{
|
199 |
+
if($first_param)
|
200 |
+
{
|
201 |
+
$param_string = (preg_match("#\?#", $pretty_link->url)?"&":"?");
|
202 |
+
$first_param = false;
|
203 |
+
}
|
204 |
+
else
|
205 |
+
$param_string .= "&";
|
206 |
+
|
207 |
+
$param_string .= "$key=$value";
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
//Redirect to Product URL
|
213 |
+
if(!isset($pretty_link->track_as_img) or $pretty_link->track_as_img == 0)
|
214 |
+
{
|
215 |
+
wp_redirect($pretty_link->url.$param_string);
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
function get_custom_forwarding_rule($param_struct)
|
220 |
+
{
|
221 |
+
$param_struct = preg_replace('#%.*?%#','(.*?)',$param_struct);
|
222 |
+
return preg_replace('#\(\.\*\?\)$#','(.*)',$param_struct); // replace the last one with a greedy operator
|
223 |
+
}
|
224 |
+
|
225 |
+
function get_custom_forwarding_params($param_struct, $start_index = 1)
|
226 |
+
{
|
227 |
+
preg_match_all('#%(.*?)%#', $param_struct, $matches);
|
228 |
+
|
229 |
+
$param_string = '';
|
230 |
+
$match_index = $start_index;
|
231 |
+
for($i = 0; $i < count($matches[1]); $i++)
|
232 |
+
{
|
233 |
+
if($i == 0 and $start_index == 1)
|
234 |
+
$param_string .= "?";
|
235 |
+
else
|
236 |
+
$param_string .= "&";
|
237 |
+
|
238 |
+
$param_string .= $matches[1][$i] . "=$$match_index";
|
239 |
+
$match_index++;
|
240 |
+
}
|
241 |
+
|
242 |
+
return $param_string;
|
243 |
+
}
|
244 |
+
|
245 |
+
function decode_custom_param_str($param_struct, $uri_string)
|
246 |
+
{
|
247 |
+
// Get the structure matches (param names)
|
248 |
+
preg_match_all('#%(.*?)%#', $param_struct, $struct_matches);
|
249 |
+
|
250 |
+
// Get the uri matches (param values)
|
251 |
+
$match_str = '#'.$this->get_custom_forwarding_rule($param_struct).'#';
|
252 |
+
preg_match($match_str, $uri_string, $uri_matches);
|
253 |
+
|
254 |
+
$param_array = array();
|
255 |
+
for($i = 0; $i < count($struct_matches[1]); $i++)
|
256 |
+
$param_array[$struct_matches[1][$i]] = $uri_matches[$i+1];
|
257 |
+
|
258 |
+
return $param_array;
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
?>
|
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","Timestamp","Referrer","Host","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->created_at\",\"$click->referer\",\"$click->host\",\"" . ((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,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<h3>For <?php echo $link_name; ?></h3>
|
5 |
+
|
6 |
+
<?php
|
7 |
+
if(isset($_GET['l']))
|
8 |
+
echo '<a href="?page='. PRLI_PLUGIN_NAME .'/prli-links.php">« Back to Links</a>';
|
9 |
+
|
10 |
+
require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
|
11 |
+
?>
|
12 |
+
|
13 |
+
<table class="widefat post fixed" cellspacing="0">
|
14 |
+
<thead>
|
15 |
+
<tr>
|
16 |
+
<th class="manage-column" width="5%">Browser</th>
|
17 |
+
<th class="manage-column" width="15%">IP</th>
|
18 |
+
<th class="manage-column" width="10%">Timestamp</th>
|
19 |
+
<th class="manage-column" width="30%">Referrer</th>
|
20 |
+
<th class="manage-column" width="30%">Host</th>
|
21 |
+
<th class="manage-column" width="10%">Link</th>
|
22 |
+
</tr>
|
23 |
+
</thead>
|
24 |
+
<?php
|
25 |
+
|
26 |
+
if(count($clicks) <= 0)
|
27 |
+
{
|
28 |
+
?>
|
29 |
+
<tr>
|
30 |
+
<td colspan="5">No Hits have been recorded yet</td>
|
31 |
+
</tr>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
else
|
35 |
+
{
|
36 |
+
foreach($clicks as $click)
|
37 |
+
{
|
38 |
+
$link = $prli_link->getOne($click->link_id);
|
39 |
+
|
40 |
+
?>
|
41 |
+
<tr>
|
42 |
+
<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>
|
43 |
+
<td><?php echo $click->ip; ?></td>
|
44 |
+
<td><?php echo $click->created_at; ?></td>
|
45 |
+
<td><?php echo $click->referer; ?></td>
|
46 |
+
<td><?php echo $click->host; ?></td>
|
47 |
+
<td><?php echo ((empty($link->name))?$link->slug:$link->name); ?></td>
|
48 |
+
</tr>
|
49 |
+
<?php
|
50 |
+
}
|
51 |
+
}
|
52 |
+
?>
|
53 |
+
<tfoot>
|
54 |
+
<tr>
|
55 |
+
<th class="manage-column">Browser</th>
|
56 |
+
<th class="manage-column">IP</th>
|
57 |
+
<th class="manage-column">Timestamp</th>
|
58 |
+
<th class="manage-column">Referrer</th>
|
59 |
+
<th class="manage-column">Host</th>
|
60 |
+
<th class="manage-column">Link</th>
|
61 |
+
</tr>
|
62 |
+
</tfoot>
|
63 |
+
</table>
|
64 |
+
<?php
|
65 |
+
if(isset($_GET['l']))
|
66 |
+
{
|
67 |
+
?>
|
68 |
+
<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>
|
69 |
+
<?php
|
70 |
+
}
|
71 |
+
else
|
72 |
+
{
|
73 |
+
?>
|
74 |
+
<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>
|
75 |
+
<?php
|
76 |
+
}
|
77 |
+
require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
|
78 |
+
?>
|
79 |
+
|
80 |
+
</div>
|
classes/views/prli-links/edit.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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" style="display:none;">
|
37 |
+
<table class="form-table">
|
38 |
+
<tr>
|
39 |
+
<td colspan="2">
|
40 |
+
<ul style="list-style-type: none">
|
41 |
+
<li>
|
42 |
+
<input type="radio" name="param_forwarding" value="off" <?php print ((!isset($_POST['param_forwarding']) or $record->param_forwarding == 'off')?'checked="true"':''); ?>/> Forward Parameters Off
|
43 |
+
<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>
|
44 |
+
</li>
|
45 |
+
<li>
|
46 |
+
<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
|
47 |
+
<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>
|
48 |
+
</li>
|
49 |
+
<li>
|
50 |
+
<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"/>
|
51 |
+
<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>
|
52 |
+
</li>
|
53 |
+
</ul>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
<tr>
|
57 |
+
<td colspan="2">
|
58 |
+
<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
|
59 |
+
<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>
|
60 |
+
</td>
|
61 |
+
</tr>
|
62 |
+
</table>
|
63 |
+
</div>
|
64 |
+
|
65 |
+
<p class="submit">
|
66 |
+
<input type="submit" name="Submit" value="Update" /> or <a href="?page=<?php print PRLI_PLUGIN_NAME ?>/prli-links.php">Cancel</a>
|
67 |
+
</p>
|
68 |
+
|
69 |
+
</form>
|
70 |
+
</div>
|
classes/views/prli-links/list.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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="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>
|
46 |
+
<th class="manage-column" width="35%"><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>
|
47 |
+
</tr>
|
48 |
+
</thead>
|
49 |
+
<?php
|
50 |
+
|
51 |
+
if($record_count <= 0)
|
52 |
+
{
|
53 |
+
?>
|
54 |
+
<tr>
|
55 |
+
<td colspan="4">No Pretty Links were found</td>
|
56 |
+
</tr>
|
57 |
+
<?php
|
58 |
+
}
|
59 |
+
else
|
60 |
+
{
|
61 |
+
foreach($links as $link)
|
62 |
+
{
|
63 |
+
$pretty_link_url = $prli_link->get_pretty_link_url($link->slug);//$prli_blogurl . '/' . $link->slug;
|
64 |
+
?>
|
65 |
+
<tr>
|
66 |
+
<td class="edit_link">
|
67 |
+
<?php if( !$link->track_as_img )
|
68 |
+
{
|
69 |
+
?>
|
70 |
+
<a href="<? print $link->url; ?>" target="_blank" title="Visit Target URL: <?php echo $link->url; ?> in a New Window"><img src="<?php echo PRLI_URL.'/images/url_icon.gif'; ?>" width="13px" height="13px" name="Visit" alt="Visit"/></a>
|
71 |
+
<a href="<? print $pretty_link_url; ?>" target="_blank" title="Visit Pretty Link: <?php echo $pretty_link_url; ?> in a New Window"><img src="<?php echo PRLI_URL.'/images/url_icon.gif'; ?>" width="13px" height="13px" name="Visit" alt="Visit"/></a>
|
72 |
+
<?php
|
73 |
+
}
|
74 |
+
else
|
75 |
+
{
|
76 |
+
?>
|
77 |
+
<img src="<?php echo PRLI_URL.'/images/pixel_track.png'; ?>" width="13px" height="13px" name="Pixel Tracking Enabled" alt="Pixel Tracking Enabled" title="Pixel Tracking Enabled"/>
|
78 |
+
<?php
|
79 |
+
}
|
80 |
+
|
81 |
+
if($link->param_forwarding == 'on')
|
82 |
+
{
|
83 |
+
?>
|
84 |
+
<img src="<?php echo PRLI_URL.'/images/forward_params.png'; ?>" width="13px" height="13px" name="Standard Parameter Forwarding Enabled" alt="Standard Parameter Forwarding Enabled" title="Standard Parameter Forwarding Enabled"/>
|
85 |
+
<?php
|
86 |
+
}
|
87 |
+
else if($link->param_forwarding == 'custom')
|
88 |
+
{
|
89 |
+
?>
|
90 |
+
<img src="<?php echo PRLI_URL.'/images/forward_params.png'; ?>" width="13px" height="13px" name="Custom Parameter Forwarding Enabled" alt="Custom Parameter Forwarding Enabled" title="Custom Parameter Forwarding Enabled"/>
|
91 |
+
<?php
|
92 |
+
}
|
93 |
+
?>
|
94 |
+
|
95 |
+
<a class="slug_name" href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php&action=edit&id=<?php print $link->id; ?>" title="Edit <?php echo $link->name; ?>"><?php echo "$link->name"; ?></a>
|
96 |
+
<br/>
|
97 |
+
<div class="link_actions" style="display:none;">
|
98 |
+
<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php&action=edit&id=<?php print $link->id; ?>" title="Edit <?php echo $link->slug; ?>">Edit</a> |
|
99 |
+
<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php&action=destroy&id=<?php print $link->id; ?>" onclick="return confirm('Are you sure you want to delete your <?php print $link->name; ?> Pretty Link? This will delete the Pretty Link and all of the statistical data about it in your database.');" title="Delete <?php echo $link->slug; ?>">Delete</a> |
|
100 |
+
<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php&action=reset&id=<?php print $link->id; ?>" onclick="return confirm('Are you sure you want to reset your <?php print $link->name; ?> Pretty Link? This will delete all of the statistical data about this Pretty Link in your database.');" title="Reset <?php echo $link->name; ?>">Reset</a> |
|
101 |
+
<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-clicks.php&l=<?php echo $link->id; ?>" title="View clicks for <?php print $link->slug; ?>">Hits</a> |
|
102 |
+
<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-reports.php&link=<?php echo $link->id; ?>" title="View stats for <?php print $link->slug; ?>">Stats</a>
|
103 |
+
<?php if( !$link->track_as_img )
|
104 |
+
{
|
105 |
+
?>
|
106 |
+
| <a href="http://twitter.com/home?status=<?php echo $pretty_link_url; ?>" target="_blank" title="Post <?php echo $pretty_link_url; ?> to Twitter">Tweet</a> |
|
107 |
+
<a href="mailto:?subject=Pretty Link&body=<?php echo $pretty_link_url; ?>" target="_blank" title="Send <?php echo $pretty_link_url; ?> in an Email">Email</a>
|
108 |
+
<?php
|
109 |
+
}
|
110 |
+
?>
|
111 |
+
</div>
|
112 |
+
</td>
|
113 |
+
<td><?php print $link->clicks; ?></td>
|
114 |
+
<td><?php print $link->created_at; ?></td>
|
115 |
+
</td>
|
116 |
+
<td><input type='text' style="font-size: 10px; width: 100%;" readonly="true" onclick='this.select();' onfocus='this.select();' value='<?php echo $pretty_link_url; ?>' /><br/>
|
117 |
+
<?php if( !$link->track_as_img )
|
118 |
+
{
|
119 |
+
?>
|
120 |
+
<span style="font-size: 8px;"><strong>Target URL:</strong> <? print $link->url; ?></span></td>
|
121 |
+
<?php
|
122 |
+
}
|
123 |
+
?>
|
124 |
+
</tr>
|
125 |
+
<?php
|
126 |
+
}
|
127 |
+
}
|
128 |
+
?>
|
129 |
+
<tfoot>
|
130 |
+
<tr>
|
131 |
+
<th class="manage-column">Name</th>
|
132 |
+
<th class="manage-column">Hits</th>
|
133 |
+
<th class="manage-column">Created</th>
|
134 |
+
<th class="manage-column">Links</th>
|
135 |
+
</tr>
|
136 |
+
</tfoot>
|
137 |
+
</table>
|
138 |
+
<?php
|
139 |
+
require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
|
140 |
+
?>
|
141 |
+
|
142 |
+
</div>
|
classes/views/prli-links/new.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|