Shortlinks by Pretty Links – Best WordPress Link Tracking Plugin - Version 1.2.5

Version Description

Download this release

Release Info

Developer supercleanse
Plugin Icon 128x128 Shortlinks by Pretty Links – Best WordPress Link Tracking Plugin
Version 1.2.5
Comparing to
See all releases

Version 1.2.5

Files changed (219) hide show
  1. classes/models/PrliClick.php +91 -0
  2. classes/models/PrliLink.php +153 -0
  3. classes/models/PrliReport.php +226 -0
  4. classes/models/PrliUtils.php +166 -0
  5. classes/models/models.inc.php +11 -0
  6. classes/views/prli-clicks/list.php +67 -0
  7. classes/views/prli-links/edit.php +48 -0
  8. classes/views/prli-links/list.php +62 -0
  9. classes/views/prli-links/new.php +48 -0
  10. classes/views/prli-reports/form.php +37 -0
  11. classes/views/shared/errors.php +19 -0
  12. classes/views/shared/table-nav.php +93 -0
  13. images/bookmark.png +0 -0
  14. images/browser/abilon.png +0 -0
  15. images/browser/adobe.png +0 -0
  16. images/browser/akregator.png +0 -0
  17. images/browser/alcatel.png +0 -0
  18. images/browser/amaya.png +0 -0
  19. images/browser/amigavoyager.png +0 -0
  20. images/browser/analogx.png +0 -0
  21. images/browser/apt.png +0 -0
  22. images/browser/avant.png +0 -0
  23. images/browser/aweb.png +0 -0
  24. images/browser/bpftp.png +0 -0
  25. images/browser/bytel.png +0 -0
  26. images/browser/chimera.png +0 -0
  27. images/browser/chrome.png +0 -0
  28. images/browser/cyberdog.png +0 -0
  29. images/browser/da.png +0 -0
  30. images/browser/dillo.png +0 -0
  31. images/browser/doris.png +0 -0
  32. images/browser/dreamcast.png +0 -0
  33. images/browser/ecatch.png +0 -0
  34. images/browser/encompass.png +0 -0
  35. images/browser/epiphany.png +0 -0
  36. images/browser/ericsson.png +0 -0
  37. images/browser/feeddemon.png +0 -0
  38. images/browser/feedreader.png +0 -0
  39. images/browser/firefox.png +0 -0
  40. images/browser/flashget.png +0 -0
  41. images/browser/fpexpress.png +0 -0
  42. images/browser/fresco.png +0 -0
  43. images/browser/freshdownload.png +0 -0
  44. images/browser/frontpage.png +0 -0
  45. images/browser/galeon.png +0 -0
  46. images/browser/getright.png +0 -0
  47. images/browser/gnome.png +0 -0
  48. images/browser/gnus.png +0 -0
  49. images/browser/gozilla.png +0 -0
  50. images/browser/hotjava.png +0 -0
  51. images/browser/httrack.png +0 -0
  52. images/browser/ibrowse.png +0 -0
  53. images/browser/icab.png +0 -0
  54. images/browser/java.png +0 -0
  55. images/browser/jetbrains_omea.png +0 -0
  56. images/browser/kmeleon.png +0 -0
  57. images/browser/konqueror.png +0 -0
  58. images/browser/leechget.png +0 -0
  59. images/browser/lg.png +0 -0
  60. images/browser/lotusnotes.png +0 -0
  61. images/browser/lynx.png +0 -0
  62. images/browser/macweb.png +0 -0
  63. images/browser/mediaplayer.png +0 -0
  64. images/browser/motorola.png +0 -0
  65. images/browser/mozilla.png +0 -0
  66. images/browser/mplayer.png +0 -0
  67. images/browser/msie.png +0 -0
  68. images/browser/msie_large.png +0 -0
  69. images/browser/multizilla.png +0 -0
  70. images/browser/ncsa_mosaic.png +0 -0
  71. images/browser/neon.png +0 -0
  72. images/browser/netnewswire.png +0 -0
  73. images/browser/netpositive.png +0 -0
  74. images/browser/netscape.png +0 -0
  75. images/browser/netscape_large.png +0 -0
  76. images/browser/netshow.png +0 -0
  77. images/browser/newsfire.png +0 -0
  78. images/browser/newsgator.png +0 -0
  79. images/browser/newzcrawler.png +0 -0
  80. images/browser/nokia.png +0 -0
  81. images/browser/notavailable.png +0 -0
  82. images/browser/omniweb.png +0 -0
  83. images/browser/opera.png +0 -0
  84. images/browser/panasonic.png +0 -0
  85. images/browser/pdaphone.png +0 -0
  86. images/browser/philips.png +0 -0
  87. images/browser/phoenix.png +0 -0
  88. images/browser/pluck.png +0 -0
  89. images/browser/pulpfiction.png +0 -0
  90. images/browser/real.png +0 -0
  91. images/browser/rss.png +0 -0
  92. images/browser/rssbandit.png +0 -0
  93. images/browser/rssowl.png +0 -0
  94. images/browser/rssreader.png +0 -0
  95. images/browser/rssxpress.png +0 -0
  96. images/browser/safari.png +0 -0
  97. images/browser/sagem.png +0 -0
  98. images/browser/samsung.png +0 -0
  99. images/browser/sharp.png +0 -0
  100. images/browser/sharpreader.png +0 -0
  101. images/browser/shrook.png +0 -0
  102. images/browser/siemens.png +0 -0
  103. images/browser/sony.png +0 -0
  104. images/browser/staroffice.png +0 -0
  105. images/browser/subversion.png +0 -0
  106. images/browser/teleport.png +0 -0
  107. images/browser/trium.png +0 -0
  108. images/browser/unknown.png +0 -0
  109. images/browser/w3c.png +0 -0
  110. images/browser/webcopier.png +0 -0
  111. images/browser/webreaper.png +0 -0
  112. images/browser/webtv.png +0 -0
  113. images/browser/webzip.png +0 -0
  114. images/browser/winxbox.png +0 -0
  115. images/browser/wizz.png +0 -0
  116. images/os/aix.png +0 -0
  117. images/os/amigaos.png +0 -0
  118. images/os/apple.png +0 -0
  119. images/os/atari.png +0 -0
  120. images/os/beos.png +0 -0
  121. images/os/bsd.png +0 -0
  122. images/os/bsdfreebsd.png +0 -0
  123. images/os/bsdi.png +0 -0
  124. images/os/bsdnetbsd.png +0 -0
  125. images/os/bsdopenbsd.png +0 -0
  126. images/os/commodore.png +0 -0
  127. images/os/cpm.png +0 -0
  128. images/os/debian.png +0 -0
  129. images/os/digital.png +0 -0
  130. images/os/dos.png +0 -0
  131. images/os/dreamcast.png +0 -0
  132. images/os/freebsd.png +0 -0
  133. images/os/gnu.png +0 -0
  134. images/os/hpux.png +0 -0
  135. images/os/ibm.png +0 -0
  136. images/os/imode.png +0 -0
  137. images/os/irix.png +0 -0
  138. images/os/java.png +0 -0
  139. images/os/kfreebsd.png +0 -0
  140. images/os/linux.png +0 -0
  141. images/os/linuxcentos.png +0 -0
  142. images/os/linuxdebian.png +0 -0
  143. images/os/linuxfedora.png +0 -0
  144. images/os/linuxgentoo.png +0 -0
  145. images/os/linuxmandr.png +0 -0
  146. images/os/linuxredhat.png +0 -0
  147. images/os/linuxsuse.png +0 -0
  148. images/os/linuxubuntu.png +0 -0
  149. images/os/mac.png +0 -0
  150. images/os/macintosh.png +0 -0
  151. images/os/macosx.png +0 -0
  152. images/os/netbsd.png +0 -0
  153. images/os/netware.png +0 -0
  154. images/os/next.png +0 -0
  155. images/os/openbsd.png +0 -0
  156. images/os/os2.png +0 -0
  157. images/os/osf.png +0 -0
  158. images/os/psp.png +0 -0
  159. images/os/qnx.png +0 -0
  160. images/os/riscos.png +0 -0
  161. images/os/sco.png +0 -0
  162. images/os/sunos.png +0 -0
  163. images/os/symbian.png +0 -0
  164. images/os/unix.png +0 -0
  165. images/os/unknown.png +0 -0
  166. images/os/vms.png +0 -0
  167. images/os/webtv.png +0 -0
  168. images/os/win.png +0 -0
  169. images/os/win16.png +0 -0
  170. images/os/win2000.png +0 -0
  171. images/os/win2003.png +0 -0
  172. images/os/win95.png +0 -0
  173. images/os/win98.png +0 -0
  174. images/os/wince.png +0 -0
  175. images/os/winlong.png +0 -0
  176. images/os/winme.png +0 -0
  177. images/os/winnt.png +0 -0
  178. images/os/winunknown.png +0 -0
  179. images/os/winxbox.png +0 -0
  180. images/os/winxp.png +0 -0
  181. images/pretty-link-add.png +0 -0
  182. images/pretty-link-med.png +0 -0
  183. images/pretty-link-small.png +0 -0
  184. images/url_icon.gif +0 -0
  185. includes/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  186. includes/jquery/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  187. includes/jquery/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  188. includes/jquery/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  189. includes/jquery/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  190. includes/jquery/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  191. includes/jquery/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  192. includes/jquery/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  193. includes/jquery/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  194. includes/jquery/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  195. includes/jquery/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  196. includes/jquery/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  197. includes/jquery/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  198. includes/jquery/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  199. includes/jquery/css/ui-lightness/jquery-ui-1.7.1.custom.css +404 -0
  200. includes/jquery/js/jquery-1.3.2.min.js +19 -0
  201. includes/jquery/js/jquery-ui-1.7.1.custom.min.js +273 -0
  202. includes/php/php_browsecap.ini +16810 -0
  203. includes/version-2-ichor/README.txt +8 -0
  204. includes/version-2-ichor/js/README.txt +12 -0
  205. includes/version-2-ichor/js/json/json2.js +461 -0
  206. includes/version-2-ichor/js/swfobject.js +5 -0
  207. includes/version-2-ichor/open-flash-chart.swf +0 -0
  208. pretty-link.php +372 -0
  209. prli-clicks.php +43 -0
  210. prli-config.php +10 -0
  211. prli-image-lookups.php +136 -0
  212. prli-links.php +109 -0
  213. prli-reports.php +9 -0
  214. prli.php +84 -0
  215. readme.txt +65 -0
  216. screenshot-1.png +0 -0
  217. screenshot-2.png +0 -0
  218. screenshot-3.png +0 -0
  219. screenshot-4.png +0 -0
classes/models/PrliClick.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 getOne( $id )
51
+ {
52
+ global $wpdb;
53
+ $click_table = $wpdb->prefix . "prli_clicks";
54
+ $query = 'SELECT * FROM ' . $this->table_name() . ' li WHERE id=' . $id;
55
+ return $wpdb->get_row($query);
56
+ }
57
+
58
+ function getAll($where = "")
59
+ {
60
+ global $wpdb;
61
+ $click_table = $wpdb->prefix . "prli_clicks";
62
+ $query = 'SELECT * FROM ' . $this->table_name() . $where . " ORDER BY created_at DESC";
63
+ return $wpdb->get_results($query);
64
+ }
65
+
66
+ // Pagination Methods
67
+ function getRecordCount($where="")
68
+ {
69
+ global $wpdb;
70
+ $query = 'SELECT COUNT(*) FROM ' . $this->table_name() . $where;
71
+ return $wpdb->get_var($query);
72
+ }
73
+
74
+ function getPageCount($p_size, $where="")
75
+ {
76
+ return ceil((int)$this->getRecordCount($where) / (int)$p_size);
77
+ }
78
+
79
+ function getPage($current_p,$p_size, $where = "")
80
+ {
81
+ global $wpdb;
82
+ $click_table = $wpdb->prefix . "prli_clicks";
83
+ $end_index = $current_p * $p_size;
84
+ $start_index = $end_index - $p_size;
85
+ $query = 'SELECT * FROM ' . $this->table_name() . $where . ' ORDER BY created_at DESC LIMIT ' . $start_index . ',' . $p_size . ';';
86
+ $results = $wpdb->get_results($query);
87
+ return $results;
88
+ }
89
+
90
+ }
91
+ ?>
classes/models/PrliLink.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $query = 'INSERT INTO ' . $this->table_name() .
14
+ ' (url,slug,forward_params,track_as_img,created_at) VALUES (\'' .
15
+ $values['url'] . '\',\'' .
16
+ $values['slug'] . '\',' .
17
+ (int)isset($values['forward_params']) . ',' .
18
+ (int)isset($values['track_as_img']) . ',' .
19
+ 'NOW())';
20
+ $query_results = $wpdb->query($query);
21
+ $wp_rewrite->flush_rules();
22
+ return $query_results;
23
+ }
24
+
25
+ function update( $id, $values )
26
+ {
27
+ global $wpdb, $wp_rewrite;
28
+ $query = 'UPDATE ' . $this->table_name() .
29
+ ' SET url=\'' . $values['url'] . '\', ' .
30
+ ' slug=\'' . $values['slug'] . '\', ' .
31
+ ' forward_params=' . (int)isset($values['forward_params']) . ', ' .
32
+ ' track_as_img=' . (int)isset($values['track_as_img']) .
33
+ ' WHERE id='.$id;
34
+ $query_results = $wpdb->query($query);
35
+ $wp_rewrite->flush_rules();
36
+ return $query_results;
37
+ }
38
+
39
+ function destroy( $id )
40
+ {
41
+ require_once(PRLI_MODELS_PATH.'/models.inc.php');
42
+ global $wpdb, $wp_rewrite;
43
+ $destroy = 'DELETE FROM ' . $this->table_name() . ' WHERE id=' . $id;
44
+ $wp_rewrite->flush_rules();
45
+ return $wpdb->query($destroy);
46
+ }
47
+
48
+ function getOne( $id )
49
+ {
50
+ global $wpdb;
51
+ $click_table = $wpdb->prefix . "prli_clicks";
52
+ $query = 'SELECT li.*, (SELECT COUNT(*) FROM ' . $click_table . ' cl WHERE cl.link_id = li.id) as clicks FROM ' . $this->table_name() . ' li WHERE id=' . $id . ';';
53
+ return $wpdb->get_row($query);
54
+ }
55
+
56
+ function getAll()
57
+ {
58
+ global $wpdb;
59
+ $click_table = $wpdb->prefix . "prli_clicks";
60
+ $query = 'SELECT li.*, (SELECT COUNT(*) FROM ' . $click_table . ' cl WHERE cl.link_id = li.id) as clicks FROM ' . $this->table_name() . ' li;';
61
+ return $wpdb->get_results($query);
62
+ }
63
+
64
+ // Pagination Methods
65
+ function getRecordCount($where="")
66
+ {
67
+ global $wpdb;
68
+ $query = 'SELECT COUNT(*) FROM ' . $this->table_name() . $where;
69
+ return $wpdb->get_var($query);
70
+ }
71
+
72
+ function getPageCount($p_size, $where="")
73
+ {
74
+ return ceil((int)$this->getRecordCount($where) / (int)$p_size);
75
+ }
76
+
77
+ function getPage($current_p,$p_size, $where = "")
78
+ {
79
+ global $wpdb;
80
+ $click_table = $wpdb->prefix . "prli_clicks";
81
+ $end_index = $current_p * $p_size;
82
+ $start_index = $end_index - $p_size;
83
+ $query = 'SELECT li.*, (SELECT COUNT(*) FROM ' . $click_table . ' cl WHERE cl.link_id = li.id) as clicks FROM ' . $this->table_name() . ' li' . $where . ' LIMIT ' . $start_index . ',' . $p_size . ';';
84
+ $results = $wpdb->get_results($query);
85
+ return $results;
86
+ }
87
+
88
+ /** I'm generating a slug that is by default 2-3 characters long.
89
+ * This gives us a possibility of 36^3 - 37 = 46,619 possible
90
+ * random slugs. That should be *more* than enough slugs for
91
+ * any website -- if I get any feedback that we need more then
92
+ * I can always make a config option to raise the # of chars.
93
+ */
94
+ function generateValidSlug($num_chars = 3)
95
+ {
96
+ global $wpdb, $prli_utils;
97
+
98
+ // We're doing a base 36 hash which is why we're always doing everything by 36
99
+ $max_slug_value = pow(36,$num_chars);
100
+ $min_slug_value = 37; // we want to have at least 2 characters in the slug
101
+ $slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
102
+
103
+ $query = "SELECT slug FROM " . $this->table_name(); // . " WHERE slug='" . $slug . "'";
104
+ $slugs = $wpdb->get_col($query,0);
105
+
106
+ // It is highly unlikely that we'll ever see 2 identical random slugs
107
+ // but just in case, here's some code to prevent collisions
108
+ while( in_array($slug,$slugs) or !$prli_utils->slugIsAvailable($slug) )
109
+ $slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
110
+
111
+ return $slug;
112
+ }
113
+
114
+ function validate( $values )
115
+ {
116
+ global $wpdb, $prli_utils;
117
+
118
+ $errors = array();
119
+ if( $values['url'] == null or $values['url'] == '' )
120
+ $errors[] = "Link URL can't be blank";
121
+
122
+ if( $values['slug'] == null or $values['slug'] == '' )
123
+ $errors[] = "Pretty Link can't be blank";
124
+
125
+ if( !preg_match('/^http.?:\/\/.*\..*$/', $values['url'] ) )
126
+ $errors[] = "Link URL must be a correctly formatted url";
127
+
128
+ if( !preg_match('/^[a-zA-Z0-9\.\-_]+$/', $values['slug'] ) )
129
+ $errors[] = "Pretty Link must not contain spaces or special characters";
130
+
131
+ if($values['id'] != null and $values['id'] != '')
132
+ $query = "SELECT slug FROM " . $this->table_name() . " WHERE slug='" . $values['slug'] . "' AND id <> " . $values['id'];
133
+ else
134
+ $query = "SELECT slug FROM " . $this->table_name() . " WHERE slug='" . $values['slug'] . "'";
135
+
136
+ $slug_already_exists = $wpdb->get_var($query);
137
+
138
+ if( $slug_already_exists or !$prli_utils->slugIsAvailable($values['slug']) )
139
+ $errors[] = "This pretty link slug is already taken, please choose a different one";
140
+
141
+ if(isset($values['track_as_img']) and $values['track_as_img'] == 'on' and $values['url'] != null and $values['url'] != '')
142
+ {
143
+ $size = getimagesize($values['url']);
144
+ if(!preg_match('#image#',$size['mime']))
145
+ {
146
+ $errors[] = "If you want to track this pretty link as an image then your target url must be an image (png, jpeg, gif, etc.)";
147
+ }
148
+ }
149
+
150
+ return $errors;
151
+ }
152
+ }
153
+ ?>
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;
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'";
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 clicks";
52
+ else
53
+ $type_string = "Unique clicks";
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# Clicks' );
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,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 get_browser_image()
157
+ {
158
+
159
+ }
160
+
161
+ function get_os_image()
162
+ {
163
+ }
164
+
165
+ }
166
+ ?>
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/list.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/>&nbsp;Pretty Link: Clicks</h2>
3
+ <h3>For <?php echo $link_name; ?></h3>
4
+
5
+ <?php
6
+ if(isset($_GET['l']))
7
+ echo '<a href="?page='. PRLI_PLUGIN_NAME .'/prli-links.php">&laquo Back to Links</a>';
8
+
9
+ require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
10
+ ?>
11
+
12
+ <table class="widefat post fixed" cellspacing="0">
13
+ <thead>
14
+ <tr>
15
+ <th class="manage-column" width="5%">Browser</th>
16
+ <th class="manage-column" width="15%">IP</th>
17
+ <th class="manage-column" width="10%">Timestamp</th>
18
+ <th class="manage-column" width="30%">Referrer</th>
19
+ <th class="manage-column" width="30%">Host</th>
20
+ <th class="manage-column" width="10%">Link</th>
21
+ </tr>
22
+ </thead>
23
+ <?php
24
+
25
+ if(count($clicks) <= 0)
26
+ {
27
+ ?>
28
+ <tr>
29
+ <td colspan="5">No Clicks have been recorded yet</td>
30
+ </tr>
31
+ <?php
32
+ }
33
+ else
34
+ {
35
+ foreach($clicks as $click)
36
+ {
37
+ $link = $prli_link->getOne($click->link_id);
38
+
39
+ ?>
40
+ <tr>
41
+ <td><img src="/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; ?>"/>&nbsp;<img src="/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>
42
+ <td><?php echo $click->ip; ?></td>
43
+ <td><?php echo $click->created_at; ?></td>
44
+ <td><?php echo $click->referer; ?></td>
45
+ <td><?php echo $click->host; ?></td>
46
+ <td><?php echo ((empty($link->name))?$link->slug:$link->name); ?></td>
47
+ </tr>
48
+ <?php
49
+ }
50
+ }
51
+ ?>
52
+ <tfoot>
53
+ <tr>
54
+ <th class="manage-column">Browser</th>
55
+ <th class="manage-column">IP</th>
56
+ <th class="manage-column">Timestamp</th>
57
+ <th class="manage-column">Referrer</th>
58
+ <th class="manage-column">Host</th>
59
+ <th class="manage-column">Link</th>
60
+ </tr>
61
+ </tfoot>
62
+ </table>
63
+ <?php
64
+ require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
65
+ ?>
66
+
67
+ </div>
classes/views/prli-links/edit.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/>&nbsp;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>
15
+ <td width="75px" valign="top">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 get_option('siteurl'); ?></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
+ </table>
25
+ <a href="#" class="advanced_toggle">Advanced Options</a>
26
+ <div class="advanced_pane" style="display:none;">
27
+ <table class="form-table">
28
+ <tr>
29
+ <td colspan="2">
30
+ <input type="checkbox" name="forward_params" <?php print ((($_POST['forward_params'] or $record->forward_params) and ($_POST['forward_params'] == 'on' or $record->forward_params == 1))?'checked="true"':''); ?>/>&nbsp; Forward Parameters (experimental)
31
+ <br/><span class="setting-description">Select this option if you want to forward custom parameters through your pretty link to your target url. Note: The Pretty Link plugin uses a parameter named <code>sprli</code> for tracking purposes and is therefore not available as one of your custom parameters.</span>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td colspan="2">
36
+ <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"':''); ?>/>&nbsp; Track as an Image (experimental)
37
+ <br/><span class="setting-description">Select this option if you want to track this link as an image 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>&lt;img src="<?php echo get_option('siteurl') . "/yourslug"; ?>" /&gt;</code>) then the image will be tracked as a click and then displayed. Note: If this option is selected your target url must be an image.</span>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </div>
42
+
43
+ <p class="submit">
44
+ <input type="submit" name="Submit" value="Update" />&nbsp;or&nbsp;<a href="?page=<?php print PRLI_PLUGIN_NAME ?>/prli-links.php">Cancel</a>
45
+ </p>
46
+
47
+ </form>
48
+ </div>
classes/views/prli-links/list.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/>&nbsp;Pretty Link: Links</h2>
3
+ <div id="message" class="updated fade" style="padding:5px;"><?php echo $prli_message; ?></div>
4
+ <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>&nbsp;|&nbsp;<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-links.php&regenerate=true">Manually Regenerate Pretty Links</a></p>
5
+ <?php
6
+ require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
7
+ ?>
8
+ <table class="widefat post fixed" cellspacing="0">
9
+ <thead>
10
+ <tr>
11
+ <th class="manage-column" width="30%">Slug</th>
12
+ <th class="manage-column" width="8%">Clicks</th>
13
+ <th class="manage-column" width="37%">URL</th>
14
+ <th class="manage-column" width="25%">Pretty Link</th>
15
+ </tr>
16
+ </thead>
17
+ <?php
18
+
19
+ if(count($links) <= 0)
20
+ {
21
+ ?>
22
+ <tr>
23
+ <td colspan="5"><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 your First Pretty Link</a></td>
24
+ </tr>
25
+ <?php
26
+ }
27
+ else
28
+ {
29
+ foreach($links as $link)
30
+ {
31
+ $pretty_link_url = get_option('siteurl') . '/' . $link->slug;
32
+ ?>
33
+ <tr>
34
+ <td class="edit_link">
35
+ <a href="<? print $pretty_link_url; ?>" target="_blank" title="Visit <?php echo $pretty_link_url; ?> in New Window"><img src="<?php echo PRLI_URL.'/images/url_icon.gif'; ?>" name="Visit" alt="Visit"/></a>&nbsp;&nbsp;<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->slug; ?>"><?php print $link->slug; ?></a>
36
+ <br/>
37
+ <div class="link_actions" style="display:none;">
38
+ <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>&nbsp;|&nbsp;<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->slug; ?> Pretty Link?');" title="Delete <?php echo $link->slug; ?>">Delete</a>&nbsp;|&nbsp;<a href="?page=<?php print PRLI_PLUGIN_NAME; ?>/prli-clicks.php&l=<?php echo $link->id; ?>" title="View clicks for <?php print $link->slug; ?>">Clicks</a>&nbsp;|&nbsp;<a href="http://twitter.com/home?status=<?php echo $pretty_link_url; ?>" target="_blank" title="Post <?php echo $pretty_link_url; ?> to Twitter">Twitter</a>&nbsp;|&nbsp;<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>
39
+ </div>
40
+ </td>
41
+ <td><?php print $link->clicks; ?></td>
42
+ <td><a href="<? print $link->url; ?>" target="_blank" title="Visit <?php echo $link->url; ?> in New Window"><img src="<?php echo PRLI_URL.'/images/url_icon.gif'; ?>" name="Visit" alt="Visit"/></a>&nbsp;&nbsp;<? print $link->url; ?></td>
43
+ <td><input type='text' style="font-size: 10px;" readonly="true" onclick='this.select();' onfocus='this.select();' value='<?php echo $pretty_link_url; ?>' size="30" /></td>
44
+ </tr>
45
+ <?php
46
+ }
47
+ }
48
+ ?>
49
+ <tfoot>
50
+ <tr>
51
+ <th class="manage-column">Slug</th>
52
+ <th class="manage-column">Clicks</th>
53
+ <th class="manage-column">URL</th>
54
+ <th class="manage-column">Pretty Link</th>
55
+ </tr>
56
+ </tfoot>
57
+ </table>
58
+ <?php
59
+ require(PRLI_VIEWS_PATH.'/shared/table-nav.php');
60
+ ?>
61
+
62
+ </div>
classes/views/prli-links/new.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/>&nbsp;Pretty Link: Add 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="create">
10
+ <?php wp_nonce_field('update-options'); ?>
11
+ <input type="hidden" name="id" value="<?php print $id; ?>">
12
+
13
+ <table class="form-table">
14
+ <tr>
15
+ <td width="75px" valign="top">URL*: </td>
16
+ <td><input type="text" name="url" value="<?php print (($_POST['url'] != null)?$_POST['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 get_option('siteurl'); ?></strong>/<input type="text" name="slug" value="<?php print (($_POST['slug'] != null)?$_POST['slug']:$prli_link->generateValidSlug()); ?>" size="25">
22
+ <br/><span class="setting-description">Use the auto-generated short slug (2-3 characters) here or enter any word (must only contain letters, numbers or the following special characters: ".","-" or "_") that will form your pretty link and redirect to the URL above. Just refresh this page to auto-generate another slug.</span></td>
23
+ </tr>
24
+ </table>
25
+ <a href="#" class="advanced_toggle">Advanced Options</a>
26
+ <div class="advanced_pane" style="display:none;">
27
+ <table class="form-table">
28
+ <tr>
29
+ <td colspan="2">
30
+ <input type="checkbox" name="forward_params" <?php print ((isset($_POST['forward_params']) and $_POST['forward_params'] == 'on')?'checked="true"':''); ?>/>&nbsp; Forward Parameters (experimental)
31
+ <br/><span class="setting-description">Select this option if you want to forward custom parameters through your pretty link to your target url. Note: The Pretty Link plugin uses a parameter named <code>sprli</code> for tracking purposes and is therefore not available as one of your custom parameters.</span>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td colspan="2">
36
+ <input type="checkbox" name="track_as_img" <?php print ((isset($_POST['track_as_img']) and $_POST['track_as_img'] == 'on')?'checked="true"':''); ?>/>&nbsp; Track as an Image (experimental)
37
+ <br/><span class="setting-description">Select this option if you want to track this link as an image 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>&lt;img src="<?php echo get_option('siteurl') . "/yourslug"; ?>" /&gt;</code>) then the image will be tracked as a click and then displayed. Note: If this option is selected your target url must be an image.</span>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </div>
42
+
43
+ <p class="submit">
44
+ <input type="submit" name="Submit" value="Create" />&nbsp;or&nbsp;<a href="?page=<?php print PRLI_PLUGIN_NAME ?>/prli-links.php">Cancel</a>
45
+ </p>
46
+
47
+ </form>
48
+ </div>
classes/views/prli-reports/form.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><img src="<?php echo PRLI_URL.'/images/pretty-link-med.png'; ?>"/>&nbsp;Pretty Link: Reports</h2>
3
+ <a href="#" class="filter_toggle">Customize Report</a>
4
+ <div class="filter_pane" style="display:none;">
5
+ <form class="form-fields" name="form2" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
6
+ <?php wp_nonce_field('prli-reports'); ?>
7
+ <span>Link:</span>&nbsp;
8
+ <select id="link" name="link" style="display: inline;">
9
+ <option value="all"<?php print ((!isset($_POST['link']) or $_POST['link'] == "all")?" selected=\"true\"":""); ?>>All&nbsp;</option>
10
+ <?php
11
+ foreach($prli_link->getAll() as $link)
12
+ {
13
+ ?>
14
+ <option value="<?php print $link->id; ?>"<?php print (($_POST['link'] == $link->id)?" selected=\"true\"":""); ?>><?php print $link->slug; ?>&nbsp;</option>
15
+ <?php
16
+ }
17
+ ?>
18
+ </select>&nbsp;
19
+ <span>Type:</span>&nbsp;
20
+ <select id="type" name="type" style="display: inline;">
21
+ <option value="all"<?php print ((!isset($_POST['type']) or $_POST['type'] == "all")?" selected=\"true\"":""); ?>>All Clicks&nbsp;</option>
22
+ <option value="unique"<?php print (($_POST['type'] == "unique")?" selected=\"true\"":""); ?>>Unique Clicks&nbsp;</option>
23
+ </select>
24
+ <br/>
25
+ <br/>
26
+ <span>Date Range:</span>
27
+ <div id="dateselectors" style="display: inline;">
28
+ <input type="text" name="sdate" id="sdate" value="<?php echo $_POST['sdate']; ?>" style="display:inline;"/>&nbsp;to&nbsp;<input type="text" name="edate" id="edate" value="<?php echo $_POST['edate']; ?>" style="display:inline;"/>
29
+ </div>
30
+ <br/>
31
+ <br/>
32
+ <div class="submit" style="display: inline;"><input type="submit" name="Submit" value="Customize"/> or <a href="#" class="filter_toggle">Cancel</a></div>
33
+ </form>
34
+ </div>
35
+ <br/>
36
+ <div id="my_chart"></div>
37
+ </div>
classes/views/shared/errors.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if( $errors != null and count($errors) > 0 )
3
+ {
4
+ ?>
5
+ <div class="error">
6
+ <ul>
7
+ <?php
8
+ foreach( $errors as $error )
9
+ {
10
+ ?>
11
+ <li><strong>ERROR</strong>: <?php print $error; ?></li>
12
+ <?php
13
+ }
14
+ ?>
15
+ </ul>
16
+ </div>
17
+ <?php
18
+ }
19
+ ?>
classes/views/shared/table-nav.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Only show the pager bar if there is more than 1 page
3
+ if($page_count > 1)
4
+ {
5
+ ?>
6
+ <div class="tablenav">
7
+ <div class='tablenav-pages'><span class="displaying-num">Displaying <?php print "$page_first_record&#8211;$page_last_record of $record_count"; ?></span>
8
+
9
+ <?php
10
+ // Only show the prev page button if the current page is not the first page
11
+ if($current_page > 1)
12
+ {
13
+ ?>
14
+ <a class='prev page-numbers' href='?page=<?php print PRLI_PLUGIN_NAME; ?>/<?php print $controller_file . $page_params; ?>&paged=<?php print($current_page-1); ?>'>&laquo;</a>
15
+ <?php
16
+ }
17
+
18
+ // First page is always displayed
19
+ if($current_page==1)
20
+ {
21
+ ?>
22
+ <span class='page-numbers current'>1</span>
23
+ <?php
24
+ }
25
+ else
26
+ {
27
+ ?>
28
+ <a class='page-numbers' href='?page=<?php print PRLI_PLUGIN_NAME; ?>/<?php print $controller_file . $page_params; ?>&paged=1'>1</a>
29
+ <?php
30
+ }
31
+
32
+ // If the current page is more than 2 spaces away from the first page then we put some dots in here
33
+ if($current_page >= 5)
34
+ {
35
+ ?>
36
+ <span class='page-numbers dots'>...</span>
37
+ <?php
38
+ }
39
+
40
+ // display the current page icon and the 2 pages beneath and above it
41
+ $low_page = (($current_page >= 5)?($current_page-2):2);
42
+ $high_page = ((($current_page + 2) < ($page_count-1))?($current_page+2):($page_count-1));
43
+ for($i = $low_page; $i <= $high_page; $i++)
44
+ {
45
+ if($current_page==$i)
46
+ {
47
+ ?>
48
+ <span class='page-numbers current'><?php print $i; ?></span>
49
+ <?php
50
+ }
51
+ else
52
+ {
53
+ ?>
54
+ <a class='page-numbers' href='?page=<?php print PRLI_PLUGIN_NAME; ?>/<?php print $controller_file . $page_params; ?>&paged=<?php print $i; ?>'><?php print $i; ?></a>
55
+ <?php
56
+ }
57
+ }
58
+
59
+ // If the current page is more than 2 away from the last page then show ellipsis
60
+ if($current_page < ($page_count - 3))
61
+ {
62
+ ?>
63
+ <span class='page-numbers dots'>...</span>
64
+ <?php
65
+ }
66
+
67
+ // Display the last page icon
68
+ if($current_page == $page_count)
69
+ {
70
+ ?>
71
+ <span class='page-numbers current'><?php print $page_count; ?></span>
72
+ <?php
73
+ }
74
+ else
75
+ {
76
+ ?>
77
+ <a class='page-numbers' href='?page=<?php print PRLI_PLUGIN_NAME; ?>/<?php print $controller_file . $page_params; ?>&paged=<?php print $page_count; ?>'><?php print $page_count; ?></a>
78
+ <?php
79
+ }
80
+
81
+ // Display the next page icon if there is a next page
82
+ if($current_page < $page_count)
83
+ {
84
+ ?>
85
+ <a class='next page-numbers' href='?page=<?php print PRLI_PLUGIN_NAME; ?>/<?php print $controller_file . $page_params; ?>&paged=<?php print($current_page + 1); ?>'>&raquo;</a>
86
+ <?php
87
+ }
88
+ ?>
89
+ </div>
90
+ </div>
91
+ <?php
92
+ }
93
+ ?>
images/bookmark.png ADDED
Binary file
images/browser/abilon.png ADDED
Binary file
images/browser/adobe.png ADDED
Binary file
images/browser/akregator.png ADDED
Binary file
images/browser/alcatel.png ADDED
Binary file
images/browser/amaya.png ADDED
Binary file
images/browser/amigavoyager.png ADDED
Binary file
images/browser/analogx.png ADDED
Binary file
images/browser/apt.png ADDED
Binary file
images/browser/avant.png ADDED
Binary file
images/browser/aweb.png ADDED
Binary file
images/browser/bpftp.png ADDED
Binary file
images/browser/bytel.png ADDED
Binary file
images/browser/chimera.png ADDED
Binary file
images/browser/chrome.png ADDED
Binary file
images/browser/cyberdog.png ADDED
Binary file
images/browser/da.png ADDED
Binary file
images/browser/dillo.png ADDED
Binary file
images/browser/doris.png ADDED
Binary file
images/browser/dreamcast.png ADDED
Binary file
images/browser/ecatch.png ADDED
Binary file
images/browser/encompass.png ADDED
Binary file
images/browser/epiphany.png ADDED
Binary file
images/browser/ericsson.png ADDED
Binary file
images/browser/feeddemon.png ADDED
Binary file
images/browser/feedreader.png ADDED
Binary file
images/browser/firefox.png ADDED
Binary file
images/browser/flashget.png ADDED
Binary file
images/browser/fpexpress.png ADDED
Binary file
images/browser/fresco.png ADDED
Binary file
images/browser/freshdownload.png ADDED
Binary file
images/browser/frontpage.png ADDED
Binary file
images/browser/galeon.png ADDED
Binary file
images/browser/getright.png ADDED
Binary file
images/browser/gnome.png ADDED
Binary file
images/browser/gnus.png ADDED
Binary file
images/browser/gozilla.png ADDED
Binary file
images/browser/hotjava.png ADDED
Binary file
images/browser/httrack.png ADDED
Binary file
images/browser/ibrowse.png ADDED
Binary file
images/browser/icab.png ADDED
Binary file
images/browser/java.png ADDED
Binary file
images/browser/jetbrains_omea.png ADDED
Binary file
images/browser/kmeleon.png ADDED
Binary file
images/browser/konqueror.png ADDED
Binary file
images/browser/leechget.png ADDED
Binary file
images/browser/lg.png ADDED
Binary file
images/browser/lotusnotes.png ADDED
Binary file
images/browser/lynx.png ADDED
Binary file
images/browser/macweb.png ADDED
Binary file
images/browser/mediaplayer.png ADDED
Binary file
images/browser/motorola.png ADDED
Binary file
images/browser/mozilla.png ADDED
Binary file
images/browser/mplayer.png ADDED
Binary file
images/browser/msie.png ADDED
Binary file
images/browser/msie_large.png ADDED
Binary file
images/browser/multizilla.png ADDED
Binary file
images/browser/ncsa_mosaic.png ADDED
Binary file