Version Description
- Refactored and Options code
- Pro: Refactored Update code to work with the upcoming WordPress 3.0
- Pro: Tweet Badge now loads asynchronously in an iFrame to prevent performance issues when updating multiple tweet badges simultaneously.
- Pro: Enabled limit on number of keyword replacements to occur per page load
- Pro: Cleaned up options code
- Pro: Added keyword replacement to comments and feeds and an option to make all links into pretty links automatically.
Download this release
Release Info
Developer | supercleanse |
Plugin | Shortlinks by Pretty Links – Best WordPress Link Tracking Plugin |
Version | 1.4.45 |
Comparing to | |
See all releases |
Version 1.4.45
- classes/models/PrliClick.php +309 -0
- classes/models/PrliGroup.php +124 -0
- classes/models/PrliLink.php +412 -0
- classes/models/PrliLinkMeta.php +59 -0
- classes/models/PrliOptions.php +271 -0
- classes/models/PrliUpdate.php +315 -0
- classes/models/PrliUrlUtils.php +164 -0
- classes/models/PrliUtils.php +1098 -0
- classes/models/models.inc.php +46 -0
- classes/views/prli-clicks/csv.php +23 -0
- classes/views/prli-clicks/csv_download.php +89 -0
- classes/views/prli-clicks/head.php +105 -0
- classes/views/prli-clicks/list.php +151 -0
- classes/views/prli-dashboard-widget/widget.php +23 -0
- classes/views/prli-groups/edit.php +58 -0
- classes/views/prli-groups/head.php +35 -0
- classes/views/prli-groups/list.php +85 -0
- classes/views/prli-groups/new.php +59 -0
- classes/views/prli-links/bar.php +13 -0
- classes/views/prli-links/edit.php +22 -0
- classes/views/prli-links/form.php +94 -0
- classes/views/prli-links/head.php +91 -0
- classes/views/prli-links/list.php +185 -0
- classes/views/prli-links/new.php +22 -0
- classes/views/prli-links/ultra-cloak.php +12 -0
- classes/views/prli-options/form.php +190 -0
- classes/views/prli-options/head.php +54 -0
- classes/views/prli-options/pro-settings.php +18 -0
- classes/views/prli-tools/form.php +20 -0
- classes/views/shared/errors.php +19 -0
- classes/views/shared/link-table-nav.php +102 -0
- classes/views/shared/nav.php +18 -0
- classes/views/shared/table-nav.php +93 -0
- images/arrow_down.png +0 -0
- images/arrow_up.png +0 -0
- images/bar_background.png +0 -0
- images/bar_map.png +0 -0
- images/bookmark.png +0 -0
- images/co.mments.gif +0 -0
- images/delicious_32.png +0 -0
- images/digg_32.png +0 -0
- images/email_32.png +0 -0
- images/facebook.png +0 -0
- images/facebook_32.png +0 -0
- images/forward_params.png +0 -0
- images/hyves_32.png +0 -0
- images/linkedin_32.png +0 -0
- images/mixx_32.png +0 -0
- images/newsvine_32.png +0 -0
- images/nofollow.png +0 -0
- images/not_tracking.png +0 -0
- images/pixel_track.png +0 -0
- images/pretty-link-48x48.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/prettylink_logo.jpg +0 -0
- images/prettylink_logo_med.jpg +0 -0
- images/prettylink_logo_small.jpg +0 -0
- images/reddit_32.png +0 -0
- images/sphinn_32.png +0 -0
- images/stumbleupon_32.png +0 -0
- images/technorati_32.png +0 -0
- images/tracking.png +0 -0
- images/twitter.png +0 -0
- images/twitter_32.png +0 -0
- images/ultra-cloak.png +0 -0
- images/url_icon.gif +0 -0
- images/whatever.txt +13 -0
- images/yahoobuzz_32.png +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 +17350 -0
- includes/version-2-kvasir/README.txt +8 -0
- includes/version-2-kvasir/js/README.txt +12 -0
- includes/version-2-kvasir/js/json/json2.js +461 -0
- includes/version-2-kvasir/js/swfobject.js +5 -0
- includes/version-2-kvasir/open-flash-chart.swf +0 -0
- pretty-bar.php +243 -0
- pretty-link.php +38 -0
- prli-add-link.php +9 -0
- prli-api.php +233 -0
- prli-bookmarklet.php +94 -0
- prli-clicks.php +454 -0
- prli-config.php +130 -0
- prli-dashboard-widget.php +13 -0
- prli-groups.php +175 -0
- prli-image-lookups.php +136 -0
- prli-links.php +236 -0
- prli-main.php +362 -0
- prli-options.php +157 -0
- prli-pro-settings.php +34 -0
- prli-tools.php +3 -0
- prli-xmlrpc.php +333 -0
- readme.txt +292 -0
classes/models/PrliClick.php
ADDED
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliClick
|
3 |
+
{
|
4 |
+
var $table_name;
|
5 |
+
|
6 |
+
function PrliClick()
|
7 |
+
{
|
8 |
+
global $wpdb;
|
9 |
+
$this->table_name = "{$wpdb->prefix}prli_clicks";
|
10 |
+
}
|
11 |
+
|
12 |
+
function get_exclude_where_clause( $where = '', $abbr = 'cl')
|
13 |
+
{
|
14 |
+
global $prli_options;
|
15 |
+
$exclude_list = trim($prli_options->prli_exclude_ips);
|
16 |
+
$filter_bots = (int)$prli_options->filter_robots;
|
17 |
+
$return_stmt = '';
|
18 |
+
|
19 |
+
if(empty($exclude_list) and $filter_bots == 0)
|
20 |
+
return $return_stmt;
|
21 |
+
|
22 |
+
$return_stmt .= (empty($where)?'':' AND');
|
23 |
+
|
24 |
+
if(!empty($exclude_list))
|
25 |
+
{
|
26 |
+
$exclude_ips = explode(',',$exclude_list);
|
27 |
+
for($i = 0; $i < count($exclude_ips); $i++)
|
28 |
+
{
|
29 |
+
$exclude_ip = trim(preg_replace('#\*#','%',$exclude_ips[$i]));
|
30 |
+
|
31 |
+
if($i > 0)
|
32 |
+
$return_stmt .= ' AND';
|
33 |
+
|
34 |
+
$return_stmt .= " {$abbr}.ip NOT LIKE '{$exclude_ip}'";
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
if($filter_bots != 0)
|
39 |
+
{
|
40 |
+
$return_stmt .= (empty($exclude_list)?' (':' AND (');
|
41 |
+
$whitelist = trim($prli_options->whitelist_ips);
|
42 |
+
|
43 |
+
if(!empty($whitelist))
|
44 |
+
{
|
45 |
+
$whitelist_ips = explode(',',$whitelist);
|
46 |
+
for($i = 0; $i <= count($whitelist_ips); $i++)
|
47 |
+
{
|
48 |
+
if($i == count($whitelist_ips))
|
49 |
+
{
|
50 |
+
$return_stmt .= ' OR';
|
51 |
+
break;
|
52 |
+
}
|
53 |
+
|
54 |
+
$whitelist_ip = trim(preg_replace('#\*#','%',$whitelist_ips[$i]));
|
55 |
+
|
56 |
+
if($i > 0)
|
57 |
+
$return_stmt .= ' OR';
|
58 |
+
|
59 |
+
$return_stmt .= " {$abbr}.ip LIKE '{$whitelist_ip}'";
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
$return_stmt .= " {$abbr}.robot=0 )";
|
65 |
+
}
|
66 |
+
|
67 |
+
return $return_stmt;
|
68 |
+
}
|
69 |
+
|
70 |
+
function getOne( $id )
|
71 |
+
{
|
72 |
+
global $wpdb, $prli_link, $prli_utils;
|
73 |
+
$query = 'SELECT cl.*, (SELECT count(*) FROM '. $this->table_name .' cl2 WHERE cl2.ip = cl.ip) as ip_count, (SELECT count(*) FROM '. $this->table_name .' cl3 WHERE cl3.vuid = cl.vuid) as vuid_count, li.name as link_name FROM ' . $this->table_name . ' cl, ' . $prli_link->table_name . ' li WHERE li.id = cl.link_id AND id=' . $id . $prli_utils->prepend_and_or_where(' AND',$this->get_exclude_where_clause());
|
74 |
+
|
75 |
+
return $wpdb->get_row($query);
|
76 |
+
}
|
77 |
+
|
78 |
+
// SELECT cl.*,li.name as link_name FROM wp_prli_clicks cl, wp_prli_links li WHERE li.id = cl.link_id ORDER BY created_at DESC
|
79 |
+
function getAll($where = '', $order = '', $include_stats = false, $limit = '')
|
80 |
+
{
|
81 |
+
global $wpdb, $prli_link, $prli_utils;
|
82 |
+
$where .= $this->get_exclude_where_clause( $where );
|
83 |
+
$where = $prli_utils->prepend_and_or_where(' AND', $where);
|
84 |
+
$limit = (empty($limit)?'':" LIMIT {$limit}");
|
85 |
+
if($include_stats)
|
86 |
+
$query = 'SELECT cl.*, (SELECT count(*) FROM '. $this->table_name .' cl2 WHERE cl2.ip = cl.ip) as ip_count, (SELECT count(*) FROM '. $this->table_name .' cl3 WHERE cl3.vuid = cl.vuid) as vuid_count, li.name as link_name FROM ' . $this->table_name . ' cl, ' . $prli_link->table_name . ' li WHERE li.id = cl.link_id' . $where . $order . $limit;
|
87 |
+
else
|
88 |
+
$query = 'SELECT cl.*, li.name as link_name FROM ' . $this->table_name . ' cl, ' . $prli_link->table_name . ' li WHERE li.id = cl.link_id' . $where . $order . $limit;
|
89 |
+
|
90 |
+
return $wpdb->get_results($query);
|
91 |
+
}
|
92 |
+
|
93 |
+
// Delete all of the clicks from the database.
|
94 |
+
function clearAllClicks()
|
95 |
+
{
|
96 |
+
global $wpdb;
|
97 |
+
$query = "TRUNCATE TABLE " . $this->table_name;
|
98 |
+
return $wpdb->query($query);
|
99 |
+
}
|
100 |
+
|
101 |
+
/* This will delete all the clicks in the database by their age measured in days. */
|
102 |
+
function clear_clicks_by_age_in_days($days)
|
103 |
+
{
|
104 |
+
global $wpdb;
|
105 |
+
|
106 |
+
$days_in_seconds = $days * 24 * 60 * 60;
|
107 |
+
$oldest_time = time() - $days_in_seconds;
|
108 |
+
|
109 |
+
$num_records = $this->getRecordCount( " UNIX_TIMESTAMP(created_at) < {$oldest_time}" );
|
110 |
+
|
111 |
+
if($num_records)
|
112 |
+
{
|
113 |
+
$query = "DELETE FROM {$this->table_name} WHERE UNIX_TIMESTAMP(created_at) < %d";
|
114 |
+
$query = $wpdb->prepare( $query, $oldest_time );
|
115 |
+
|
116 |
+
$wpdb->query($query);
|
117 |
+
}
|
118 |
+
|
119 |
+
return $num_records;
|
120 |
+
}
|
121 |
+
|
122 |
+
function get_distinct_ip_count($where='')
|
123 |
+
{
|
124 |
+
global $wpdb, $prli_link, $prli_utils;
|
125 |
+
$where .= $this->get_exclude_where_clause( $where );
|
126 |
+
$where = $prli_utils->prepend_and_or_where(' WHERE', $where);
|
127 |
+
$query = 'SELECT COUNT(DISTINCT ip) FROM ' . $this->table_name . ' cl'. $where;
|
128 |
+
return $wpdb->get_var($query);
|
129 |
+
}
|
130 |
+
|
131 |
+
// Pagination Methods
|
132 |
+
function getRecordCount($where='')
|
133 |
+
{
|
134 |
+
global $wpdb, $prli_link, $prli_utils;
|
135 |
+
$where .= $this->get_exclude_where_clause( $where );
|
136 |
+
$where = $prli_utils->prepend_and_or_where(' WHERE', $where);
|
137 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name . ' cl'. $where;
|
138 |
+
|
139 |
+
return $wpdb->get_var($query);
|
140 |
+
}
|
141 |
+
|
142 |
+
function getPageCount($p_size, $where='')
|
143 |
+
{
|
144 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
145 |
+
}
|
146 |
+
|
147 |
+
function getPage($current_p,$p_size, $where = '', $order = '',$include_stats=false)
|
148 |
+
{
|
149 |
+
global $wpdb, $prli_link, $prli_utils;
|
150 |
+
$end_index = $current_p * $p_size;
|
151 |
+
$start_index = $end_index - $p_size;
|
152 |
+
$where .= $this->get_exclude_where_clause( $where );
|
153 |
+
$where = $prli_utils->prepend_and_or_where(' AND', $where);
|
154 |
+
if($include_stats)
|
155 |
+
$query = 'SELECT cl.*, (SELECT count(*) FROM '. $this->table_name .' cl2 WHERE cl2.ip = cl.ip) as ip_count, (SELECT count(*) FROM '. $this->table_name .' cl3 WHERE cl3.vuid = cl.vuid) as vuid_count, li.name as link_name FROM ' . $this->table_name . ' cl, ' . $prli_link->table_name . ' li WHERE li.id = cl.link_id' . $where . $order . ' LIMIT ' . $start_index . ',' . $p_size . ';';
|
156 |
+
else
|
157 |
+
$query = 'SELECT cl.*, li.name as link_name FROM ' . $this->table_name . ' cl, ' . $prli_link->table_name . ' li WHERE li.id = cl.link_id' . $where . $order . ' LIMIT ' . $start_index . ',' . $p_size . ';';
|
158 |
+
$results = $wpdb->get_results($query);
|
159 |
+
return $results;
|
160 |
+
}
|
161 |
+
|
162 |
+
function generateUniqueVisitorId($num_chars = 6)
|
163 |
+
{
|
164 |
+
global $wpdb, $prli_utils;
|
165 |
+
|
166 |
+
// We're doing a base 36 hash which is why we're always doing everything by 36
|
167 |
+
$max_vuid_value = pow(36,$num_chars);
|
168 |
+
$min_vuid_value = 37;
|
169 |
+
$vuid = base_convert( mt_rand($min_vuid_value,$max_vuid_value), 10, 36 );
|
170 |
+
|
171 |
+
$query = "SELECT DISTINCT vuid FROM ".$this->table_name;
|
172 |
+
$vuids = $wpdb->get_col($query,0);
|
173 |
+
|
174 |
+
// It is highly unlikely that we'll ever see 2 identical random vuids
|
175 |
+
// but just in case, here's some code to prevent collisions
|
176 |
+
while( in_array($vuid,$vuids) )
|
177 |
+
$vuid = base_convert( mt_rand($min_vuid_value,$max_vuid_value), 10, 36 );
|
178 |
+
|
179 |
+
return $vuid;
|
180 |
+
}
|
181 |
+
|
182 |
+
function get_counts_by_days($start_timestamp, $end_timestamp, $link_id = "all", $type = "all", $group = '')
|
183 |
+
{
|
184 |
+
global $wpdb, $prli_link;
|
185 |
+
|
186 |
+
$query = "SELECT DATE(cl.created_at) as cldate,COUNT(*) as clcount FROM ".$this->table_name." cl WHERE cl.created_at BETWEEN '".date("Y-n-j",$start_timestamp)." 00:00:00' AND '".date("Y-n-j",$end_timestamp)." 23:59:59'".$search_where.$this->get_exclude_where_clause( ' AND' );
|
187 |
+
|
188 |
+
if($link_id != "all")
|
189 |
+
$query .= " AND link_id=$link_id";
|
190 |
+
|
191 |
+
if(!empty($group))
|
192 |
+
$query .= " AND link_id IN (SELECT id FROM " . $prli_link->table_name . " WHERE group_id=$group)";
|
193 |
+
|
194 |
+
if($type == "unique")
|
195 |
+
$query .= " AND first_click=1";
|
196 |
+
|
197 |
+
$query .= ' GROUP BY DATE(cl.created_at)';
|
198 |
+
|
199 |
+
$clicks_array = $wpdb->get_results($query);
|
200 |
+
|
201 |
+
$temp_array = array();
|
202 |
+
$counts_array = array();
|
203 |
+
$dates_array = array();
|
204 |
+
|
205 |
+
// Refactor Array for use later on
|
206 |
+
foreach($clicks_array as $c)
|
207 |
+
$temp_array[$c->cldate] = $c->clcount;
|
208 |
+
|
209 |
+
// Get the dates array
|
210 |
+
for($c = $start_timestamp; $c <= $end_timestamp; $c += 60*60*24)
|
211 |
+
$dates_array[] = date("Y-m-d",$c);
|
212 |
+
|
213 |
+
// Make sure counts array is in order and includes zero click days
|
214 |
+
foreach($dates_array as $date_str)
|
215 |
+
{
|
216 |
+
if(isset($temp_array[$date_str]))
|
217 |
+
$counts_array[$date_str] = $temp_array[$date_str];
|
218 |
+
else
|
219 |
+
$counts_array[$date_str] = 0;
|
220 |
+
}
|
221 |
+
|
222 |
+
return $counts_array;
|
223 |
+
}
|
224 |
+
|
225 |
+
|
226 |
+
function setupClickLineGraph($start_timestamp,$end_timestamp, $link_id = "all", $type = "all", $group = '')
|
227 |
+
{
|
228 |
+
global $wpdb, $prli_utils, $prli_link, $prli_group;
|
229 |
+
|
230 |
+
$dates_array = $this->get_counts_by_days($start_timestamp,$end_timestamp,$link_id,$type,$group);
|
231 |
+
|
232 |
+
$top_click_count = $prli_utils->getTopValue(array_values($dates_array));
|
233 |
+
|
234 |
+
if(!empty($group))
|
235 |
+
$link_slug = "group: '" . $wpdb->get_var("SELECT name FROM ".$prli_group->table_name." WHERE id=$group") . "'";
|
236 |
+
else if($link_id == "all")
|
237 |
+
$link_slug = "all links";
|
238 |
+
else
|
239 |
+
$link_slug = "'/".$wpdb->get_var("SELECT slug FROM ".$prli_link->table_name." WHERE id=$link_id") . "'";
|
240 |
+
|
241 |
+
if($type == "all")
|
242 |
+
$type_string = "All hits";
|
243 |
+
else
|
244 |
+
$type_string = "Unique hits";
|
245 |
+
|
246 |
+
$json_array = array(
|
247 |
+
"elements" => array( array(
|
248 |
+
"type" => "line",
|
249 |
+
"values" => array_values($dates_array),
|
250 |
+
"dot-style" => array(
|
251 |
+
"type" => "dot",
|
252 |
+
"dot-size" => 4,
|
253 |
+
"colour" => "#ffc94e",
|
254 |
+
"halo-size" => 1,
|
255 |
+
"tip" => "#val# Hits<br>#x_label#"
|
256 |
+
),
|
257 |
+
"width" => 2
|
258 |
+
) ),
|
259 |
+
"title" => array(
|
260 |
+
"text" => 'Pretty Link: '.$type_string.' on '.$link_slug. ' between ' . date("Y-n-j",$start_timestamp) . ' and ' . date("Y-n-j",$end_timestamp),
|
261 |
+
"style" => "font-size: 16px; font-weight: bold; color: #3030d0; text-align: center; padding-bottom: 5px;"
|
262 |
+
),
|
263 |
+
"bg_colour" => "-1",
|
264 |
+
"y_axis" => array(
|
265 |
+
"min" => 0,
|
266 |
+
"max" => $top_click_count,
|
267 |
+
"steps" => (int)(($top_click_count>=10)?$top_click_count/10:1),
|
268 |
+
"colour" => "#A2ACBA"
|
269 |
+
),
|
270 |
+
"x_axis" => array(
|
271 |
+
"colour" => "#A2ACBA",
|
272 |
+
"grid-colour" => "#ffefa7",
|
273 |
+
"offset" => false,
|
274 |
+
"steps" => 4,
|
275 |
+
"labels" => array(
|
276 |
+
"steps" => 2,
|
277 |
+
"rotate" => 25,
|
278 |
+
"colour" => "#000000",
|
279 |
+
"labels" => array_keys($dates_array)
|
280 |
+
)
|
281 |
+
)
|
282 |
+
);
|
283 |
+
|
284 |
+
return $prli_utils->prli_json_encode($json_array);
|
285 |
+
}
|
286 |
+
|
287 |
+
|
288 |
+
// Set defaults and grab get or post of each possible param
|
289 |
+
function get_params_array()
|
290 |
+
{
|
291 |
+
$values = array(
|
292 |
+
'paged' => (isset($_GET['paged'])?$_GET['paged']:(isset($_POST['paged'])?$_POST['paged']:1)),
|
293 |
+
'l' => (isset($_GET['l'])?$_GET['l']:(isset($_POST['l'])?$_POST['l']:'all')),
|
294 |
+
'group' => (isset($_GET['group'])?$_GET['group']:(isset($_POST['group'])?$_POST['group']:'')),
|
295 |
+
'ip' => (isset($_GET['ip'])?$_GET['ip']:(isset($_POST['ip'])?$_POST['ip']:'')),
|
296 |
+
'vuid' => (isset($_GET['vuid'])?$_GET['vuid']:(isset($_POST['vuid'])?$_POST['vuid']:'')),
|
297 |
+
'sdate' => (isset($_GET['sdate'])?$_GET['sdate']:(isset($_POST['sdate'])?$_POST['sdate']:'')),
|
298 |
+
'edate' => (isset($_GET['edate'])?$_GET['edate']:(isset($_POST['edate'])?$_POST['edate']:'')),
|
299 |
+
'type' => (isset($_GET['type'])?$_GET['type']:(isset($_POST['type'])?$_POST['type']:'all')),
|
300 |
+
'search' => (isset($_GET['search'])?$_GET['search']:(isset($_POST['search'])?$_POST['search']:'')),
|
301 |
+
'sort' => (isset($_GET['sort'])?$_GET['sort']:(isset($_POST['sort'])?$_POST['sort']:'')),
|
302 |
+
'sdir' => (isset($_GET['sdir'])?$_GET['sdir']:(isset($_POST['sdir'])?$_POST['sdir']:''))
|
303 |
+
);
|
304 |
+
|
305 |
+
return $values;
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
?>
|
classes/models/PrliGroup.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliGroup
|
3 |
+
{
|
4 |
+
var $table_name;
|
5 |
+
|
6 |
+
function PrliGroup()
|
7 |
+
{
|
8 |
+
global $wpdb;
|
9 |
+
$this->table_name = "{$wpdb->prefix}prli_groups";
|
10 |
+
}
|
11 |
+
|
12 |
+
function create( $values )
|
13 |
+
{
|
14 |
+
global $wpdb, $wp_rewrite;
|
15 |
+
|
16 |
+
$query = 'INSERT INTO ' . $this->table_name .
|
17 |
+
' (name,description,created_at) VALUES (\'' .
|
18 |
+
$values['name'] . '\',\'' .
|
19 |
+
$values['description'] . '\',' .
|
20 |
+
'NOW())';
|
21 |
+
$query_results = $wpdb->query($query);
|
22 |
+
return $wpdb->insert_id;
|
23 |
+
}
|
24 |
+
|
25 |
+
function update( $id, $values )
|
26 |
+
{
|
27 |
+
global $wpdb, $wp_rewrite;
|
28 |
+
|
29 |
+
$query = 'UPDATE ' . $this->table_name .
|
30 |
+
' SET name=\'' . $values['name'] . '\', ' .
|
31 |
+
' description=\'' . $values['description'] . '\' ' .
|
32 |
+
' WHERE id='.$id;
|
33 |
+
$query_results = $wpdb->query($query);
|
34 |
+
return $query_results;
|
35 |
+
}
|
36 |
+
|
37 |
+
function destroy( $id )
|
38 |
+
{
|
39 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
40 |
+
global $wpdb, $prli_link, $wp_rewrite;
|
41 |
+
|
42 |
+
// Disconnect the links from this group
|
43 |
+
$query = 'UPDATE ' . $prli_link->table_name .
|
44 |
+
' SET group_id = NULL ' .
|
45 |
+
' WHERE group_id='.$id;
|
46 |
+
$query_results = $wpdb->query($query);
|
47 |
+
|
48 |
+
$destroy = 'DELETE FROM ' . $this->table_name . ' WHERE id=' . $id;
|
49 |
+
return $wpdb->query($destroy);
|
50 |
+
}
|
51 |
+
|
52 |
+
function getOne( $id, $include_stats = false )
|
53 |
+
{
|
54 |
+
global $wpdb, $prli_link, $prli_click;
|
55 |
+
|
56 |
+
if($include_stats)
|
57 |
+
$query = 'SELECT gr.*, (SELECT COUNT(*) FROM ' . $prli_link->table_name . ' li WHERE li.group_id = gr.id) as link_count FROM ' . $this->table_name . ' gr WHERE id=' . $id;
|
58 |
+
else
|
59 |
+
$query = 'SELECT gr.* FROM ' . $this->table_name . ' gr WHERE id=' . $id;
|
60 |
+
return $wpdb->get_row($query);
|
61 |
+
}
|
62 |
+
|
63 |
+
function getAll( $where = '', $order_by = '', $return_type = OBJECT, $include_stats = false )
|
64 |
+
{
|
65 |
+
global $wpdb, $prli_utils, $prli_link, $prli_click;
|
66 |
+
|
67 |
+
if($include_stats)
|
68 |
+
$query = 'SELECT gr.*, (SELECT COUNT(*) FROM ' . $prli_link->table_name . ' li WHERE li.group_id = gr.id) as link_count FROM ' . $this->table_name . ' gr' . $prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by;
|
69 |
+
else
|
70 |
+
$query = 'SELECT gr.* FROM ' . $this->table_name . " gr" . $prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by;
|
71 |
+
return $wpdb->get_results($query, $return_type);
|
72 |
+
}
|
73 |
+
|
74 |
+
// Pagination Methods
|
75 |
+
function getRecordCount($where="")
|
76 |
+
{
|
77 |
+
global $wpdb, $prli_utils;
|
78 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name . $prli_utils->prepend_and_or_where(' WHERE', $where);
|
79 |
+
return $wpdb->get_var($query);
|
80 |
+
}
|
81 |
+
|
82 |
+
function getPageCount($p_size, $where="")
|
83 |
+
{
|
84 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
85 |
+
}
|
86 |
+
|
87 |
+
function getPage($current_p,$p_size, $where = "", $order_by = '')
|
88 |
+
{
|
89 |
+
global $wpdb, $prli_link, $prli_utils, $prli_click;
|
90 |
+
$end_index = $current_p * $p_size;
|
91 |
+
$start_index = $end_index - $p_size;
|
92 |
+
$query = 'SELECT gr.*, (SELECT COUNT(*) FROM ' . $prli_link->table_name . ' li WHERE li.group_id = gr.id) as link_count FROM ' . $this->table_name . ' gr' . $prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by .' LIMIT ' . $start_index . ',' . $p_size;
|
93 |
+
$results = $wpdb->get_results($query);
|
94 |
+
return $results;
|
95 |
+
}
|
96 |
+
|
97 |
+
// Set defaults and grab get or post of each possible param
|
98 |
+
function get_params_array()
|
99 |
+
{
|
100 |
+
$values = array(
|
101 |
+
'action' => (isset($_GET['action'])?$_GET['action']:(isset($_POST['action'])?$_POST['action']:'list')),
|
102 |
+
'id' => (isset($_GET['id'])?$_GET['id']:(isset($_POST['id'])?$_POST['id']:'')),
|
103 |
+
'paged' => (isset($_GET['paged'])?$_GET['paged']:(isset($_POST['paged'])?$_POST['paged']:1)),
|
104 |
+
'group' => (isset($_GET['group'])?$_GET['group']:(isset($_POST['group'])?$_POST['group']:'')),
|
105 |
+
'search' => (isset($_GET['search'])?$_GET['search']:(isset($_POST['search'])?$_POST['search']:'')),
|
106 |
+
'sort' => (isset($_GET['sort'])?$_GET['sort']:(isset($_POST['sort'])?$_POST['sort']:'')),
|
107 |
+
'sdir' => (isset($_GET['sdir'])?$_GET['sdir']:(isset($_POST['sdir'])?$_POST['sdir']:''))
|
108 |
+
);
|
109 |
+
|
110 |
+
return $values;
|
111 |
+
}
|
112 |
+
|
113 |
+
function validate( $values )
|
114 |
+
{
|
115 |
+
global $wpdb, $prli_utils;
|
116 |
+
|
117 |
+
$errors = array();
|
118 |
+
if( empty($values['name']) )
|
119 |
+
$errors[] = "Group must have a name.";
|
120 |
+
|
121 |
+
return $errors;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
?>
|
classes/models/PrliLink.php
ADDED
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliLink
|
3 |
+
{
|
4 |
+
var $table_name;
|
5 |
+
|
6 |
+
function PrliLink()
|
7 |
+
{
|
8 |
+
global $wpdb;
|
9 |
+
$this->table_name = "{$wpdb->prefix}prli_links";
|
10 |
+
}
|
11 |
+
|
12 |
+
function create( $values )
|
13 |
+
{
|
14 |
+
global $wpdb, $prli_url_utils;
|
15 |
+
|
16 |
+
if($values['redirect_type'] == 'pixel')
|
17 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$values['slug']);
|
18 |
+
else
|
19 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$prli_url_utils->get_title($values['url'],$values['slug']));
|
20 |
+
|
21 |
+
$query_str = "INSERT INTO {$this->table_name} " .
|
22 |
+
'(url,'.
|
23 |
+
'slug,'.
|
24 |
+
'name,'.
|
25 |
+
'param_forwarding,'.
|
26 |
+
'param_struct,'.
|
27 |
+
'redirect_type,'.
|
28 |
+
'description,'.
|
29 |
+
'track_me,'.
|
30 |
+
'nofollow,'.
|
31 |
+
'group_id,'.
|
32 |
+
'created_at) ' .
|
33 |
+
'VALUES (%s,%s,%s,%s,%s,%s,%s,%d,%d,%d,NOW())';
|
34 |
+
|
35 |
+
$query = $wpdb->prepare( $query_str,
|
36 |
+
$values['url'],
|
37 |
+
$values['slug'],
|
38 |
+
$values['name'],
|
39 |
+
$values['param_forwarding'],
|
40 |
+
$values['param_struct'],
|
41 |
+
$values['redirect_type'],
|
42 |
+
$values['description'],
|
43 |
+
(int)isset($values['track_me']),
|
44 |
+
(int)isset($values['nofollow']),
|
45 |
+
(isset($values['group_id'])?(int)$values['group_id']:'NULL') );
|
46 |
+
$query_results = $wpdb->query($query);
|
47 |
+
|
48 |
+
if($query_results)
|
49 |
+
return $wpdb->insert_id;
|
50 |
+
else
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
function update( $id, $values )
|
55 |
+
{
|
56 |
+
global $wpdb, $prli_url_utils;
|
57 |
+
|
58 |
+
if($values['redirect_type'] == 'pixel')
|
59 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$values['slug']);
|
60 |
+
else
|
61 |
+
$values['name'] = (!empty($values['name'])?$values['name']:$prli_url_utils->get_title($values['url'],$values['slug']));
|
62 |
+
|
63 |
+
$query_str = "UPDATE {$this->table_name} " .
|
64 |
+
'SET url=%s, ' .
|
65 |
+
'slug=%s, ' .
|
66 |
+
'name=%s, ' .
|
67 |
+
'param_forwarding=%s, ' .
|
68 |
+
'param_struct=%s, ' .
|
69 |
+
'redirect_type=%s, ' .
|
70 |
+
'description=%s, ' .
|
71 |
+
'track_me=%d, ' .
|
72 |
+
'nofollow=%d, ' .
|
73 |
+
'group_id=%d ' .
|
74 |
+
' WHERE id=%d';
|
75 |
+
|
76 |
+
$query = $wpdb->prepare( $query_str,
|
77 |
+
$values['url'],
|
78 |
+
$values['slug'],
|
79 |
+
$values['name'],
|
80 |
+
$values['param_forwarding'],
|
81 |
+
$values['param_struct'],
|
82 |
+
$values['redirect_type'],
|
83 |
+
$values['description'],
|
84 |
+
(int)isset($values['track_me']),
|
85 |
+
(int)isset($values['nofollow']),
|
86 |
+
(isset($values['group_id'])?(int)$values['group_id']:'NULL'),
|
87 |
+
$id );
|
88 |
+
|
89 |
+
$query_results = $wpdb->query($query);
|
90 |
+
return $query_results;
|
91 |
+
}
|
92 |
+
|
93 |
+
function update_group( $id, $value, $group_id )
|
94 |
+
{
|
95 |
+
global $wpdb;
|
96 |
+
$query = 'UPDATE ' . $this->table_name .
|
97 |
+
' SET group_id=' . (isset($value)?$group_id:'NULL') .
|
98 |
+
' WHERE id='.$id;
|
99 |
+
$query_results = $wpdb->query($query);
|
100 |
+
return $query_results;
|
101 |
+
}
|
102 |
+
|
103 |
+
function destroy( $id )
|
104 |
+
{
|
105 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
106 |
+
global $wpdb, $prli_click;
|
107 |
+
|
108 |
+
$reset = 'DELETE FROM ' . $prli_click->table_name . ' WHERE link_id=' . $id;
|
109 |
+
$destroy = 'DELETE FROM ' . $this->table_name . ' WHERE id=' . $id;
|
110 |
+
|
111 |
+
$wpdb->query($reset);
|
112 |
+
return $wpdb->query($destroy);
|
113 |
+
}
|
114 |
+
|
115 |
+
function reset( $id )
|
116 |
+
{
|
117 |
+
require_once(PRLI_MODELS_PATH.'/models.inc.php');
|
118 |
+
global $wpdb, $prli_click;
|
119 |
+
|
120 |
+
$reset = 'DELETE FROM ' . $prli_click->table_name . ' WHERE link_id=' . $id;
|
121 |
+
return $wpdb->query($reset);
|
122 |
+
}
|
123 |
+
|
124 |
+
function getOneFromSlug( $slug, $return_type = OBJECT, $include_stats = false )
|
125 |
+
{
|
126 |
+
global $wpdb, $prli_click;
|
127 |
+
if($include_stats)
|
128 |
+
$query = 'SELECT li.*, ' .
|
129 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
130 |
+
'WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks, ' .
|
131 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
132 |
+
'WHERE cl.link_id = li.id ' .
|
133 |
+
'AND cl.first_click <> 0' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as uniques ' .
|
134 |
+
"FROM {$this->table_name} li " .
|
135 |
+
'WHERE slug=%s';
|
136 |
+
else
|
137 |
+
$query = "SELECT * FROM {$this->table_name} WHERE slug=%s";
|
138 |
+
|
139 |
+
$query = $wpdb->prepare($query, $slug);
|
140 |
+
return $wpdb->get_row($query, $return_type);
|
141 |
+
}
|
142 |
+
|
143 |
+
function getOne( $id, $return_type = OBJECT, $include_stats = false )
|
144 |
+
{
|
145 |
+
global $wpdb, $prli_click;
|
146 |
+
if( !isset($id) or empty($id) )
|
147 |
+
return false;
|
148 |
+
|
149 |
+
if($include_stats)
|
150 |
+
$query = 'SELECT li.*, ' .
|
151 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
152 |
+
'WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks, ' .
|
153 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
154 |
+
'WHERE cl.link_id = li.id ' .
|
155 |
+
'AND cl.first_click <> 0' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as uniques ' .
|
156 |
+
'FROM ' . $this->table_name . ' li ' .
|
157 |
+
'WHERE id=%d';
|
158 |
+
else
|
159 |
+
$query = "SELECT * FROM {$this->table_name} WHERE id=%d";
|
160 |
+
|
161 |
+
$query = $wpdb->prepare($query, $id);
|
162 |
+
return $wpdb->get_row($query, $return_type);
|
163 |
+
}
|
164 |
+
|
165 |
+
function find_first_target_url($target_url)
|
166 |
+
{
|
167 |
+
global $wpdb;
|
168 |
+
$query_str = "SELECT id FROM {$this->table_name} WHERE url=%s LIMIT 1";
|
169 |
+
$query = $wpdb->prepare($query_str,$target_url);
|
170 |
+
return $wpdb->get_var($query);
|
171 |
+
}
|
172 |
+
|
173 |
+
function &get_or_create_pretty_link_for_target_url( $target_url, $group=0 )
|
174 |
+
{
|
175 |
+
$pretty_link_id = $this->find_first_target_url( $target_url );
|
176 |
+
$pretty_link = $this->getOne($pretty_link_id);
|
177 |
+
|
178 |
+
if(empty($pretty_link) or !$pretty_link)
|
179 |
+
{
|
180 |
+
$pl_insert_id = prli_create_pretty_link( $target_url, '', '', '', $group );
|
181 |
+
$pretty_link = $this->getOne($pl_insert_id);
|
182 |
+
}
|
183 |
+
else
|
184 |
+
prli_update_pretty_link( $pretty_link->id, '', '', '', '', $group );
|
185 |
+
|
186 |
+
if( !isset($pretty_link) or
|
187 |
+
empty($pretty_link) or
|
188 |
+
!$pretty_link )
|
189 |
+
return false;
|
190 |
+
else
|
191 |
+
return $pretty_link;
|
192 |
+
}
|
193 |
+
|
194 |
+
function &is_pretty_link($url, $check_domain=true)
|
195 |
+
{
|
196 |
+
global $prli_blogurl;
|
197 |
+
|
198 |
+
if( !$check_domain or preg_match( '#^' . preg_quote( $prli_blogurl ) . '#', $url ) )
|
199 |
+
{
|
200 |
+
$uri = preg_replace('#' . preg_quote($prli_blogurl) . '#', '', $url);
|
201 |
+
|
202 |
+
// Resolve WP installs in sub-directories
|
203 |
+
preg_match('#^(https?://.*?)(/.*)$#', $prli_blogurl, $subdir);
|
204 |
+
|
205 |
+
$struct = PrliUtils::get_permalink_pre_slug_regex();
|
206 |
+
|
207 |
+
$subdir_str = (isset($subdir[1])?$subdir[1]:'');
|
208 |
+
|
209 |
+
$match_str = '#^'.$subdir_str.'('.$struct.')([^\?]*?)([\?].*?)?$#';
|
210 |
+
|
211 |
+
if(preg_match($match_str, $uri, $match_val))
|
212 |
+
{
|
213 |
+
// Match longest slug -- this is the most common
|
214 |
+
$params = $match_val[3];
|
215 |
+
if( $pretty_link_found =& $this->is_pretty_link_slug( $match_val[2] ) )
|
216 |
+
return compact('pretty_link_found','pretty_link_params');
|
217 |
+
|
218 |
+
// Trim down the matched link
|
219 |
+
$matched_link = preg_replace('#/[^/]*?$#','',$match_val[2],1);
|
220 |
+
|
221 |
+
// cycle through the links (maximum depth 25 folders so we don't get out
|
222 |
+
// of control -- that should be enough eh?) and trim the link down each time
|
223 |
+
for( $i=0; ($i < 25) and
|
224 |
+
$matched_link and
|
225 |
+
!empty($matched_link) and
|
226 |
+
$matched_link != $match_val[2]; $i++ )
|
227 |
+
{
|
228 |
+
$new_match_str ="#^{$subdir_str}({$struct})({$matched_link})(.*?)?$#";
|
229 |
+
|
230 |
+
$params = $match_val[3];
|
231 |
+
if( $pretty_link_found =& $this->is_pretty_link_slug( $match_val[2] ) )
|
232 |
+
return compact('pretty_link_found','pretty_link_params');
|
233 |
+
|
234 |
+
// Trim down the matched link and try again
|
235 |
+
$matched_link = preg_replace('#/[^/]*$#','',$match_val[2],1);
|
236 |
+
}
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
return false;
|
241 |
+
}
|
242 |
+
|
243 |
+
function &is_pretty_link_slug($slug)
|
244 |
+
{
|
245 |
+
return $this->getOneFromSlug( urldecode($slug) );
|
246 |
+
}
|
247 |
+
|
248 |
+
function get_link_min( $id, $return_type = OBJECT )
|
249 |
+
{
|
250 |
+
global $wpdb;
|
251 |
+
$query_str = "SELECT * FROM {$this->table_name} WHERE id=%d";
|
252 |
+
$query = $wpdb->prepare($query_str, $id);
|
253 |
+
return $wpdb->get_row($query, $return_type);
|
254 |
+
}
|
255 |
+
|
256 |
+
function getAll($where = '', $order_by = '', $return_type = OBJECT, $include_stats = false)
|
257 |
+
{
|
258 |
+
global $wpdb, $prli_click, $prli_group, $prli_utils;
|
259 |
+
|
260 |
+
if($include_stats)
|
261 |
+
$query = 'SELECT li.*, ' .
|
262 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
263 |
+
'WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks, ' .
|
264 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
265 |
+
'WHERE cl.link_id = li.id ' .
|
266 |
+
'AND cl.first_click <> 0' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as uniques, ' .
|
267 |
+
'gr.name as group_name ' .
|
268 |
+
'FROM '. $this->table_name . ' li ' .
|
269 |
+
'LEFT OUTER JOIN ' . $prli_group->table_name . ' gr ON li.group_id=gr.id' .
|
270 |
+
$prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by;
|
271 |
+
else
|
272 |
+
$query = "SELECT li.*, gr.name as group_name FROM {$this->table_name} li " .
|
273 |
+
'LEFT OUTER JOIN ' . $prli_group->table_name . ' gr ON li.group_id=gr.id' .
|
274 |
+
$prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by;
|
275 |
+
|
276 |
+
return $wpdb->get_results($query, $return_type);
|
277 |
+
}
|
278 |
+
|
279 |
+
// Pagination Methods
|
280 |
+
function getRecordCount($where="")
|
281 |
+
{
|
282 |
+
global $wpdb, $prli_utils;
|
283 |
+
$query = 'SELECT COUNT(*) FROM ' . $this->table_name . ' li' . $prli_utils->prepend_and_or_where(' WHERE', $where);
|
284 |
+
return $wpdb->get_var($query);
|
285 |
+
}
|
286 |
+
|
287 |
+
function getPageCount($p_size, $where="")
|
288 |
+
{
|
289 |
+
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
290 |
+
}
|
291 |
+
|
292 |
+
function getPage($current_p,$p_size, $where = "", $order_by = '', $return_type = OBJECT)
|
293 |
+
{
|
294 |
+
global $wpdb, $prli_click, $prli_utils, $prli_group;
|
295 |
+
$end_index = $current_p * $p_size;
|
296 |
+
$start_index = $end_index - $p_size;
|
297 |
+
$query = 'SELECT li.*, ' .
|
298 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
299 |
+
'WHERE cl.link_id = li.id' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as clicks, ' .
|
300 |
+
'(SELECT COUNT(*) FROM ' . $prli_click->table_name . ' cl ' .
|
301 |
+
'WHERE cl.link_id = li.id ' .
|
302 |
+
'AND cl.first_click <> 0' . $prli_click->get_exclude_where_clause( ' AND' ) . ') as uniques, ' .
|
303 |
+
'gr.name as group_name ' .
|
304 |
+
'FROM ' . $this->table_name . ' li ' .
|
305 |
+
'LEFT OUTER JOIN ' . $prli_group->table_name . ' gr ON li.group_id=gr.id' .
|
306 |
+
$prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by . ' ' .
|
307 |
+
'LIMIT ' . $start_index . ',' . $p_size . ';';
|
308 |
+
$results = $wpdb->get_results($query, $return_type);
|
309 |
+
return $results;
|
310 |
+
}
|
311 |
+
|
312 |
+
/** I'm generating a slug that is by default 2-3 characters long.
|
313 |
+
* This gives us a possibility of 36^3 - 37 = 46,619 possible
|
314 |
+
* random slugs. That should be *more* than enough slugs for
|
315 |
+
* any website -- if I get any feedback that we need more then
|
316 |
+
* I can always make a config option to raise the # of chars.
|
317 |
+
*/
|
318 |
+
function generateValidSlug($num_chars = 3)
|
319 |
+
{
|
320 |
+
global $wpdb, $prli_utils;
|
321 |
+
|
322 |
+
// We're doing a base 36 hash which is why we're always doing everything by 36
|
323 |
+
$max_slug_value = pow(36,$num_chars);
|
324 |
+
$min_slug_value = 37; // we want to have at least 2 characters in the slug
|
325 |
+
$slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
|
326 |
+
|
327 |
+
$query = "SELECT slug FROM " . $this->table_name; // . " WHERE slug='" . $slug . "'";
|
328 |
+
$slugs = $wpdb->get_col($query,0);
|
329 |
+
|
330 |
+
// It is highly unlikely that we'll ever see 2 identical random slugs
|
331 |
+
// but just in case, here's some code to prevent collisions
|
332 |
+
while( in_array($slug,$slugs) or !$prli_utils->slugIsAvailable($slug) )
|
333 |
+
$slug = base_convert( rand($min_slug_value,$max_slug_value), 10, 36 );
|
334 |
+
|
335 |
+
return $slug;
|
336 |
+
}
|
337 |
+
|
338 |
+
function get_pretty_link_url($slug)
|
339 |
+
{
|
340 |
+
global $prli_blogurl;
|
341 |
+
|
342 |
+
$link = $this->getOneFromSlug($slug);
|
343 |
+
|
344 |
+
if((isset($link->param_forwarding) and $link->param_forwarding == 'custom') and
|
345 |
+
(isset($link->redirect_type) and $link->redirect_type == 'pixel'))
|
346 |
+
return "<img src=\"".$prli_blogurl . PrliUtils::get_permalink_pre_slug_uri() . $link->slug . $link->param_struct . "\" width=\"1\" height=\"1\" style=\"display: none\" />";
|
347 |
+
else if((!isset($link->param_forwarding) or $link->param_forwarding != 'custom') and
|
348 |
+
(isset($link->redirect_type) and $link->redirect_type == 'pixel'))
|
349 |
+
return "<img src=\"".$prli_blogurl . PrliUtils::get_permalink_pre_slug_uri() . $link->slug . "\" width=\"1\" height=\"1\" style=\"display: none\" />";
|
350 |
+
else if((isset($link->param_forwarding) and $link->param_forwarding == 'custom') and
|
351 |
+
(!isset($link->redirect_type) or $link->redirect_type != 'pixel'))
|
352 |
+
return $prli_blogurl . PrliUtils::get_permalink_pre_slug_uri() . $link->slug . $link->param_struct;
|
353 |
+
else
|
354 |
+
return $prli_blogurl . PrliUtils::get_permalink_pre_slug_uri() . $link->slug;
|
355 |
+
}
|
356 |
+
|
357 |
+
// Set defaults and grab get or post of each possible param
|
358 |
+
function get_params_array()
|
359 |
+
{
|
360 |
+
$values = array(
|
361 |
+
'action' => (isset($_GET['action'])?$_GET['action']:(isset($_POST['action'])?$_POST['action']:'list')),
|
362 |
+
'regenerate' => (isset($_GET['regenerate'])?$_GET['regenerate']:(isset($_POST['regenerate'])?$_POST['regenerate']:'false')),
|
363 |
+
'id' => (isset($_GET['id'])?$_GET['id']:(isset($_POST['id'])?$_POST['id']:'')),
|
364 |
+
'group_name' => (isset($_GET['group_name'])?$_GET['group_name']:(isset($_POST['group_name'])?$_POST['group_name']:'')),
|
365 |
+
'paged' => (isset($_GET['paged'])?$_GET['paged']:(isset($_POST['paged'])?$_POST['paged']:1)),
|
366 |
+
'group' => (isset($_GET['group'])?$_GET['group']:(isset($_POST['group'])?$_POST['group']:'')),
|
367 |
+
'search' => (isset($_GET['search'])?$_GET['search']:(isset($_POST['search'])?$_POST['search']:'')),
|
368 |
+
'sort' => (isset($_GET['sort'])?$_GET['sort']:(isset($_POST['sort'])?$_POST['sort']:'')),
|
369 |
+
'sdir' => (isset($_GET['sdir'])?$_GET['sdir']:(isset($_POST['sdir'])?$_POST['sdir']:''))
|
370 |
+
);
|
371 |
+
|
372 |
+
return $values;
|
373 |
+
}
|
374 |
+
|
375 |
+
function validate( $values )
|
376 |
+
{
|
377 |
+
global $wpdb, $prli_utils, $prli_blogurl;
|
378 |
+
|
379 |
+
$errors = array();
|
380 |
+
if( ( $values['url'] == null or $values['url'] == '') and $values['redirect_type'] != 'pixel' )
|
381 |
+
$errors[] = "Target URL can't be blank";
|
382 |
+
|
383 |
+
if( $values['slug'] == null or $values['slug'] == '' )
|
384 |
+
$errors[] = "Pretty Link can't be blank";
|
385 |
+
|
386 |
+
if( $values['url'] == $prli_blogurl.PrliUtils::get_permalink_pre_slug_uri().$values['slug'] )
|
387 |
+
$errors[] = "Target URL must be different than the Pretty Link";
|
388 |
+
|
389 |
+
if( !empty($values['url']) and
|
390 |
+
!preg_match('/^http.?:\/\/.*\..*$/', $values['url'] ) and
|
391 |
+
!preg_match('!^(http|https)://(localhost|127\.0\.0\.1)(:\d+)?(/[\w- ./?%&=]*)?!', $values['url'] ) )
|
392 |
+
$errors[] = "Link URL must be a correctly formatted url";
|
393 |
+
|
394 |
+
if( preg_match('/^[\?\&\#]+$/', $values['slug'] ) )
|
395 |
+
$errors[] = "Pretty Link slugs must not contain question marks, ampersands or number signs.";
|
396 |
+
|
397 |
+
if( preg_match('#/$#', $values['slug']) )
|
398 |
+
$errors[] = "Pretty Link slugs must not end with a slash (\"/\")";
|
399 |
+
|
400 |
+
if( !$prli_utils->slugIsAvailable($values['slug'],$values['id']) )
|
401 |
+
$errors[] = "This Pretty Link Slug is already taken. Check to make sure it isn't being used by another pretty link, post, page, category or tag slug. If none of these are true then check to see that this slug isn't the name of a file in the root folder of your wordpress install.";
|
402 |
+
|
403 |
+
if( isset($values['param_forwarding']) and $values['param_forwarding'] == 'custom' and empty($values['param_struct']) )
|
404 |
+
$errors[] = "If Custom Parameter Forwarding has been selected then you must specify a forwarding format.";
|
405 |
+
|
406 |
+
if( isset($values['param_forwarding']) and $values['param_forwarding'] == 'custom' and !preg_match('#%.*?%#', $values['param_struct']) )
|
407 |
+
$errors[] = "Your parameter forwarding must have at least one parameter specified in the format ex: <code>/%var1%/%var_two%/%varname3% ...</code>";
|
408 |
+
|
409 |
+
return $errors;
|
410 |
+
}
|
411 |
+
}
|
412 |
+
?>
|
classes/models/PrliLinkMeta.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliLinkMeta
|
3 |
+
{
|
4 |
+
var $table_name;
|
5 |
+
|
6 |
+
function PrliLinkMeta()
|
7 |
+
{
|
8 |
+
global $wpdb;
|
9 |
+
$this->table_name = "{$wpdb->prefix}prli_link_metas";
|
10 |
+
}
|
11 |
+
|
12 |
+
function get_link_meta($link_id,$meta_key,$return_var=false)
|
13 |
+
{
|
14 |
+
global $wpdb;
|
15 |
+
$query_str = "SELECT meta_value FROM {$this->table_name} WHERE meta_key=%s and link_id=%d";
|
16 |
+
$query = $wpdb->prepare($query_str,$meta_key,$link_id);
|
17 |
+
|
18 |
+
if($return_var)
|
19 |
+
return $wpdb->get_var("{$query} LIMIT 1");
|
20 |
+
else
|
21 |
+
return $wpdb->get_col($query, 0);
|
22 |
+
}
|
23 |
+
|
24 |
+
function add_link_meta($link_id, $meta_key, $meta_value)
|
25 |
+
{
|
26 |
+
global $wpdb;
|
27 |
+
|
28 |
+
$query_str = "INSERT INTO {$this->table_name} " .
|
29 |
+
'(meta_key,meta_value,link_id,created_at) VALUES (%s,%s,%d,NOW())';
|
30 |
+
$query = $wpdb->prepare($query_str, $meta_key, $meta_value, $link_id);
|
31 |
+
return $wpdb->query($query);
|
32 |
+
}
|
33 |
+
|
34 |
+
function update_link_meta($link_id, $meta_key, $meta_values)
|
35 |
+
{
|
36 |
+
global $wpdb;
|
37 |
+
$this->delete_link_meta($link_id, $meta_key);
|
38 |
+
|
39 |
+
if(!is_array($meta_values))
|
40 |
+
$meta_values = array($meta_values);
|
41 |
+
|
42 |
+
$status = false;
|
43 |
+
foreach($meta_values as $meta_value)
|
44 |
+
$status = $this->add_link_meta($link_id, $meta_key, $meta_value);
|
45 |
+
|
46 |
+
return $status;
|
47 |
+
}
|
48 |
+
|
49 |
+
function delete_link_meta($link_id, $meta_key)
|
50 |
+
{
|
51 |
+
global $wpdb;
|
52 |
+
|
53 |
+
$query_str = "DELETE FROM {$this->table_name} " .
|
54 |
+
"WHERE meta_key=%s AND link_id=%d";
|
55 |
+
$query = $wpdb->prepare($query_str, $meta_key, $link_id);
|
56 |
+
return $wpdb->query($query);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
?>
|
classes/models/PrliOptions.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PrliOptions
|
3 |
+
{
|
4 |
+
var $prli_exclude_ips;
|
5 |
+
var $whitelist_ips;
|
6 |
+
var $filter_robots;
|
7 |
+
var $prettybar_image_url;
|
8 |
+
var $prettybar_background_image_url;
|
9 |
+
var $prettybar_color;
|
10 |
+
var $prettybar_text_color;
|
11 |
+
var $prettybar_link_color;
|
12 |
+
var $prettybar_hover_color;
|
13 |
+
var $prettybar_visited_color;
|
14 |
+
var $prettybar_show_title;
|
15 |
+
var $prettybar_show_description;
|
16 |
+
var $prettybar_show_share_links;
|
17 |
+
var $prettybar_show_target_url_link;
|
18 |
+
var $prettybar_title_limit;
|
19 |
+
var $prettybar_desc_limit;
|
20 |
+
var $prettybar_link_limit;
|
21 |
+
|
22 |
+
var $link_redirect_type;
|
23 |
+
var $link_prefix;
|
24 |
+
var $link_track_me;
|
25 |
+
var $link_nofollow;
|
26 |
+
|
27 |
+
var $bookmarklet_auth;
|
28 |
+
|
29 |
+
function PrliOptions()
|
30 |
+
{
|
31 |
+
$this->set_default_options();
|
32 |
+
}
|
33 |
+
|
34 |
+
function set_default_options()
|
35 |
+
{
|
36 |
+
// Must account for the Legacy Options
|
37 |
+
$prli_exclude_ips = 'prli_exclude_ips';
|
38 |
+
$prettybar_image_url = 'prli_prettybar_image_url';
|
39 |
+
$prettybar_background_image_url = 'prli_prettybar_background_image_url';
|
40 |
+
$prettybar_color = 'prli_prettybar_color';
|
41 |
+
$prettybar_text_color = 'prli_prettybar_text_color';
|
42 |
+
$prettybar_link_color = 'prli_prettybar_link_color';
|
43 |
+
$prettybar_hover_color = 'prli_prettybar_hover_color';
|
44 |
+
$prettybar_visited_color = 'prli_prettybar_visited_color';
|
45 |
+
$prettybar_show_title = 'prli_prettybar_show_title';
|
46 |
+
$prettybar_show_description = 'prli_prettybar_show_description';
|
47 |
+
$prettybar_show_share_links = 'prli_prettybar_show_share_links';
|
48 |
+
$prettybar_show_target_url_link = 'prli_prettybar_show_target_url_link';
|
49 |
+
$prettybar_title_limit = 'prli_prettybar_title_limit';
|
50 |
+
$prettybar_desc_limit = 'prli_prettybar_desc_limit';
|
51 |
+
$prettybar_link_limit = 'prli_prettybar_link_limit';
|
52 |
+
$link_show_prettybar = 'prli_link_show_prettybar';
|
53 |
+
$link_ultra_cloak = 'prli_link_ultra_cloak';
|
54 |
+
$link_track_me = 'prli_link_track_me';
|
55 |
+
$link_prefix = 'prli_link_prefix';
|
56 |
+
$link_track_as_pixel = 'prli_link_track_as_pixel';
|
57 |
+
$link_nofollow = 'prli_link_nofollow';
|
58 |
+
$link_redirect_type = 'prli_link_redirect_type';
|
59 |
+
|
60 |
+
|
61 |
+
if(!isset($this->prettybar_show_title)) {
|
62 |
+
if($var = get_option( $prettybar_show_title )) {
|
63 |
+
$this->prettybar_show_title = $var;
|
64 |
+
delete_option( $prettybar_show_title );
|
65 |
+
}
|
66 |
+
else
|
67 |
+
$this->prettybar_show_title = '1';
|
68 |
+
}
|
69 |
+
|
70 |
+
if(!isset($this->prettybar_show_description)) {
|
71 |
+
if($var = get_option( $prettybar_show_description )) {
|
72 |
+
$this->prettybar_show_description = $var;
|
73 |
+
delete_option( $prettybar_show_description );
|
74 |
+
}
|
75 |
+
else
|
76 |
+
$this->prettybar_show_description = '1';
|
77 |
+
}
|
78 |
+
|
79 |
+
if(!isset($this->prettybar_show_share_links)) {
|
80 |
+
if($var = get_option( $prettybar_show_share_links )) {
|
81 |
+
$this->prettybar_show_share_links = $var;
|
82 |
+
delete_option( $prettybar_show_share_links );
|
83 |
+
}
|
84 |
+
else
|
85 |
+
$this->prettybar_show_share_links = '1';
|
86 |
+
}
|
87 |
+
|
88 |
+
if(!isset($this->prettybar_show_target_url_link)) {
|
89 |
+
if($var = get_option( $prettybar_show_target_url_link )) {
|
90 |
+
$this->prettybar_show_target_url_link = $var;
|
91 |
+
delete_option( $prettybar_show_target_url_link );
|
92 |
+
}
|
93 |
+
else
|
94 |
+
$this->prettybar_show_target_url_link = '1';
|
95 |
+
}
|
96 |
+
|
97 |
+
if(!isset($this->link_track_me)) {
|
98 |
+
if($var = get_option( $link_track_me )) {
|
99 |
+
$this->link_track_me = $var;
|
100 |
+
delete_option( $link_track_me );
|
101 |
+
}
|
102 |
+
else
|
103 |
+
$this->link_track_me = '1';
|
104 |
+
}
|
105 |
+
|
106 |
+
if(!isset($this->link_prefix))
|
107 |
+
$this->link_prefix = 0;
|
108 |
+
|
109 |
+
if(!isset($this->link_nofollow)) {
|
110 |
+
if($var = get_option( $link_nofollow )) {
|
111 |
+
$this->link_nofollow = $var;
|
112 |
+
delete_option( $link_nofollow );
|
113 |
+
}
|
114 |
+
else
|
115 |
+
$this->link_nofollow = '0';
|
116 |
+
}
|
117 |
+
|
118 |
+
if(!isset($this->link_redirect_type)) {
|
119 |
+
if($var = get_option( $link_track_as_pixel )) {
|
120 |
+
$this->link_redirect_type = 'pixel';
|
121 |
+
delete_option( $link_show_prettybar );
|
122 |
+
delete_option( $link_ultra_cloak );
|
123 |
+
delete_option( $link_track_as_pixel );
|
124 |
+
delete_option( $link_redirect_type );
|
125 |
+
}
|
126 |
+
if($var = get_option( $link_show_prettybar )) {
|
127 |
+
$this->link_redirect_type = 'prettybar';
|
128 |
+
delete_option( $link_show_prettybar );
|
129 |
+
delete_option( $link_ultra_cloak );
|
130 |
+
delete_option( $link_track_as_pixel );
|
131 |
+
delete_option( $link_redirect_type );
|
132 |
+
}
|
133 |
+
if($var = get_option( $link_ultra_cloak )) {
|
134 |
+
$this->link_redirect_type = 'cloak';
|
135 |
+
delete_option( $link_show_prettybar );
|
136 |
+
delete_option( $link_ultra_cloak );
|
137 |
+
delete_option( $link_track_as_pixel );
|
138 |
+
delete_option( $link_redirect_type );
|
139 |
+
}
|
140 |
+
if($var = get_option( $link_redirect_type )) {
|
141 |
+
$this->link_redirect_type = $var;
|
142 |
+
delete_option( $link_show_prettybar );
|
143 |
+
delete_option( $link_ultra_cloak );
|
144 |
+
delete_option( $link_track_as_pixel );
|
145 |
+
delete_option( $link_redirect_type );
|
146 |
+
}
|
147 |
+
else
|
148 |
+
$this->link_redirect_type = '307';
|
149 |
+
}
|
150 |
+
|
151 |
+
if(!isset($this->prli_exclude_ips))
|
152 |
+
{
|
153 |
+
if($var = get_option( $prli_exclude_ips )) {
|
154 |
+
$this->prli_exclude_ips = $var;
|
155 |
+
delete_option( $prli_exclude_ips );
|
156 |
+
}
|
157 |
+
else
|
158 |
+
$this->prli_exclude_ips = '';
|
159 |
+
}
|
160 |
+
|
161 |
+
if(!isset($this->prettybar_image_url))
|
162 |
+
{
|
163 |
+
if($var = get_option( $prettybar_image_url )) {
|
164 |
+
$this->prettybar_image_url = $var;
|
165 |
+
delete_option( $prettybar_image_url );
|
166 |
+
}
|
167 |
+
else
|
168 |
+
$this->prettybar_image_url = PRLI_URL . '/images/pretty-link-48x48.png';
|
169 |
+
}
|
170 |
+
|
171 |
+
if(!isset($this->prettybar_background_image_url))
|
172 |
+
{
|
173 |
+
if($var = get_option( $prettybar_background_image_url )) {
|
174 |
+
$this->prettybar_background_image_url = $var;
|
175 |
+
delete_option( $prettybar_background_image_url );
|
176 |
+
}
|
177 |
+
else
|
178 |
+
$this->prettybar_background_image_url = PRLI_URL . '/images/bar_background.png';
|
179 |
+
}
|
180 |
+
|
181 |
+
if(!isset($this->prettybar_color))
|
182 |
+
{
|
183 |
+
if($var = get_option( $prettybar_color )) {
|
184 |
+
$this->prettybar_color = $var;
|
185 |
+
delete_option( $prettybar_color );
|
186 |
+
}
|
187 |
+
else
|
188 |
+
$this->prettybar_color = '';
|
189 |
+
}
|
190 |
+
|
191 |
+
if(!isset($this->prettybar_text_color))
|
192 |
+
{
|
193 |
+
if($var = get_option( $prettybar_text_color )) {
|
194 |
+
$this->prettybar_text_color = $var;
|
195 |
+
delete_option( $prettybar_text_color );
|
196 |
+
}
|
197 |
+
else
|
198 |
+
$this->prettybar_text_color = '000000';
|
199 |
+
}
|
200 |
+
|
201 |
+
if(!isset($this->prettybar_link_color))
|
202 |
+
{
|
203 |
+
if($var = get_option( $prettybar_link_color )) {
|
204 |
+
$this->prettybar_link_color = $var;
|
205 |
+
delete_option( $prettybar_link_color );
|
206 |
+
}
|
207 |
+
else
|
208 |
+
$this->prettybar_link_color = '0000ee';
|
209 |
+
}
|
210 |
+
|
211 |
+
if(!isset($this->prettybar_hover_color))
|
212 |
+
{
|
213 |
+
if($var = get_option( $prettybar_hover_color )) {
|
214 |
+
$this->prettybar_hover_color = $var;
|
215 |
+
delete_option( $prettybar_hover_color );
|
216 |
+
}
|
217 |
+
else
|
218 |
+
$this->prettybar_hover_color = 'ababab';
|
219 |
+
}
|
220 |
+
|
221 |
+
if(!isset($this->prettybar_visited_color))
|
222 |
+
{
|
223 |
+
if($var = get_option( $prettybar_visited_color )) {
|
224 |
+
$this->prettybar_visited_color = $var;
|
225 |
+
delete_option( $prettybar_visited_color );
|
226 |
+
}
|
227 |
+
else
|
228 |
+
$this->prettybar_visited_color = '551a8b';
|
229 |
+
}
|
230 |
+
|
231 |
+
if(!isset($this->prettybar_title_limit))
|
232 |
+
{
|
233 |
+
if($var = get_option( $prettybar_title_limit )) {
|
234 |
+
$this->prettybar_title_limit = $var;
|
235 |
+
delete_option( $prettybar_title_limit );
|
236 |
+
}
|
237 |
+
else
|
238 |
+
$this->prettybar_title_limit = '25';
|
239 |
+
}
|
240 |
+
|
241 |
+
if(!isset($this->prettybar_desc_limit))
|
242 |
+
{
|
243 |
+
if($var = get_option( $prettybar_desc_limit )) {
|
244 |
+
$this->prettybar_desc_limit = $var;
|
245 |
+
delete_option( $prettybar_desc_limit );
|
246 |
+
}
|
247 |
+
else
|
248 |
+
$this->prettybar_desc_limit = '30';
|
249 |
+
}
|
250 |
+
|
251 |
+
if(!isset($this->prettybar_link_limit))
|
252 |
+
{
|
253 |
+
if($var = get_option( $prettybar_link_limit )) {
|
254 |
+
$this->prettybar_link_limit = $var;
|
255 |
+
delete_option( $prettybar_link_limit );
|
256 |
+
}
|
257 |
+
else
|
258 |
+
$this->prettybar_link_limit = '30';
|
259 |
+
}
|
260 |
+
|
261 |
+
if(!isset($this->bookmarklet_auth))
|
262 |
+
$this->bookmarklet_auth = md5(get_option('auth_salt') . time());
|
263 |
+
|
264 |
+
if(!isset($this->whitelist_ips))
|
265 |
+
$this->whitelist_ips = '';
|
266 |
+
|
267 |
+
if(!isset($this->filter_robots))
|
268 |
+
$this->filter_robots = 0;
|
269 |
+
}
|
270 |
+
}
|
271 |
+
?>
|
classes/models/PrliUpdate.php
ADDED
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|