Changeset 1486
- Timestamp:
- 09/23/09 17:29:51 (14 years ago)
- Location:
- plugins/rateIt
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/rateIt/_define.php
r1458 r1486 18 18 /* Description*/ "Rating system for your posts", 19 19 /* Author */ "JC Denis", 20 /* Version */ '0.9. 5',20 /* Version */ '0.9.6', 21 21 /* Permissions */ 'admin' 22 22 ); 23 /* date */ #200909 0923 /* date */ #20090923 24 24 ?> -
plugins/rateIt/_public.php
r1458 r1486 83 83 if (!$core->blog->settings->rateit_active) { 84 84 self::p404(); 85 exit;85 return; 86 86 } 87 87 88 88 if (!preg_match('#([^/]+)/([^/]+)$#',$args,$m)) { 89 89 self::p404(); 90 exit;90 return; 91 91 } 92 92 93 93 if (!isset($_POST['rateit-'.$m[1].'-'.$m[2]])) { 94 94 self::p404(); 95 exit;95 return; 96 96 } 97 97 … … 112 112 if ($post->post_id) { 113 113 http::redirect($core->blog->url.$core->url->getBase('post').'/'.$post->post_url.($voted ? '#rateit' : '')); 114 exit;114 return; 115 115 } 116 116 } … … 120 120 if ($comment->comment_id) { 121 121 http::redirect($core->blog->url.$core->url->getBase('post').'/'.$post->post_url.($voted ? '#rateit' : '')); 122 return; 122 123 } 123 124 } … … 127 128 if ($cat->cat_id) { 128 129 http::redirect($core->blog->url.$core->url->getBase('category').'/'.$cat->cat_url.($voted ? '#rateit' : '')); 130 return; 129 131 } 130 132 } … … 135 137 if ($metas->meta_id) { 136 138 http::redirect($core->blog->url.$core->url->getBase('tag').'/'.$metas->meta_id.($voted ? '#rateit' : '')); 139 return; 137 140 } 138 141 } … … 142 145 if ($gal->cat_id) { 143 146 http::redirect($core->blog->url.$core->url->getBase('galleries').'/'.$gal->post_url.($voted ? '#rateit' : '')); 147 return; 144 148 } 145 149 } … … 149 153 if ($gal->cat_id) { 150 154 http::redirect($core->blog->url.$core->url->getBase('gal').'/'.$gal->post_url.($voted ? '#rateit' : '')); 155 return; 151 156 } 152 157 } … … 156 161 157 162 http::redirect($core->blog->url); 158 exit;163 return; 159 164 } 160 165 … … 165 170 if (!$core->blog->settings->rateit_active) { 166 171 self::p404(); 167 exit;172 return; 168 173 } 169 174 170 175 if (!preg_match('#^(.*?)$#',$args,$m)) { 171 176 self::p404(); 172 exit;177 return; 173 178 } 174 179 175 180 if (!($f = self::searchRateItTplFiles($m[1]))) { 176 181 self::p404(); 177 exit;182 return; 178 183 } 179 184 … … 181 186 if (!file_exists($f) || !in_array(files::getExtension($f),$allowed_types)) { 182 187 self::p404(); 183 exit;188 return; 184 189 } 185 190 … … 193 198 echo preg_replace('#url\((?!(http:)|/)#','url('.$core->blog->url.$core->url->getBase('rateItmodule').'/',file_get_contents($f)); 194 199 } 195 exit;200 return; 196 201 } 197 202 … … 643 648 644 649 $p = array('from'=>'','sql'=>'','columns'=>array()); 645 $p['order'] = ($w->sortby && in_array($w->sortby,array('rateit_avg','rateit_total' ))) ?650 $p['order'] = ($w->sortby && in_array($w->sortby,array('rateit_avg','rateit_total','rateit_time'))) ? 646 651 $w->sortby.' ' : 'rateit_total '; 647 652 -
plugins/rateIt/_widgets.php
r1406 r1486 112 112 $w->rateitrank->setting('sortby',__('Order by:'),'rateit_avg','combo',array( 113 113 __('Note') => 'rateit_avg', 114 __('Votes') => 'rateit_total')); 114 __('Votes') => 'rateit_total', 115 __('Date') => 'rateit_time')); 115 116 $w->rateitrank->setting('sort',__('Sort:'),'desc','combo',array( 116 117 __('Ascending') => 'asc', -
plugins/rateIt/inc/class.rateit.php
r1458 r1486 17 17 { 18 18 public $core; 19 public $con; 20 private $blog; 19 21 private $table; 20 22 private $quotient; … … 27 29 { 28 30 $this->core =& $core; 31 $this->con = $core->con; 32 $this->blog = $core->con->escape($core->blog->id); 29 33 $this->table = $core->prefix.'rateit'; 30 34 $this->quotient = $core->blog->settings->rateit_quotient; … … 58 62 return false; 59 63 60 $cur = $this->co re->con->openCursor($this->table);61 $this->co re->con->writeLock($this->table);62 63 $cur->blog_id = $this-> core->blog->id;64 $cur = $this->con->openCursor($this->table); 65 $this->con->writeLock($this->table); 66 67 $cur->blog_id = $this->blog; 64 68 $cur->rateit_type = (string) $type; 65 69 $cur->rateit_id = (string) $id; … … 75 79 76 80 $cur->insert(); 77 $this->co re->con->unlock();81 $this->con->unlock(); 78 82 $this->core->blog->triggerBlog(); 79 83 … … 93 97 $req= 94 98 'SELECT rateit_note, rateit_quotient '. 95 'FROM '.$this->table.' WHERE blog_id=\''.$this-> core->con->escape($this->core->blog->id).'\' ';99 'FROM '.$this->table.' WHERE blog_id=\''.$this->blog.'\' '; 96 100 if ($type!=null) 97 $req .= 'AND rateit_type=\''.$this->co re->con->escape($type).'\' ';101 $req .= 'AND rateit_type=\''.$this->con->escape($type).'\' '; 98 102 if ($id!=null) 99 $req .= 'AND rateit_id=\''.$this->co re->con->escape($id).'\' ';103 $req .= 'AND rateit_id=\''.$this->con->escape($id).'\' '; 100 104 if ($ip!=null) 101 $req .= 'AND rateit_ip=\''.$this->co re->con->escape($ip).'\' ';102 103 $rs = $this->co re->con->select($req);105 $req .= 'AND rateit_ip=\''.$this->con->escape($ip).'\' '; 106 107 $rs = $this->con->select($req); 104 108 $rs->toStatic(); 105 109 … … 135 139 public function voted($type=null,$id=null) 136 140 { 137 $rs = $this->co re->con->select(141 $rs = $this->con->select( 138 142 'SELECT COUNT(*) '. 139 143 'FROM '.$this->table.' '. 140 'WHERE blog_id=\''.$this-> core->con->escape($this->core->blog->id).'\' '.141 'AND rateit_ip=\''.$this->co re->con->escape($this->ip).'\' '.144 'WHERE blog_id=\''.$this->blog.'\' '. 145 'AND rateit_ip=\''.$this->con->escape($this->ip).'\' '. 142 146 ($type!=null ? 143 'AND rateit_type=\''.$this->co re->con->escape($type).'\' ' : '').147 'AND rateit_type=\''.$this->con->escape($type).'\' ' : ''). 144 148 ($id!=null ? 145 'AND rateit_id=\''.$this->co re->con->escape($id).'\' ' : '')149 'AND rateit_id=\''.$this->con->escape($id).'\' ' : '') 146 150 ); 147 151 $sql = (boolean) $rs->f(0); … … 157 161 $req = 158 162 'DELETE FROM '.$this->table.' '. 159 'WHERE blog_id=\''.$this-> core->con->escape($this->core->blog->id).'\' ';163 'WHERE blog_id=\''.$this->blog.'\' '; 160 164 if (null !== $type) 161 $req .= 'AND rateit_type=\''.$this->co re->con->escape($type).'\' ';165 $req .= 'AND rateit_type=\''.$this->con->escape($type).'\' '; 162 166 if (null !== $id) 163 $req .= 'AND rateit_id=\''.$this->co re->con->escape($id).'\' ';167 $req .= 'AND rateit_id=\''.$this->con->escape($id).'\' '; 164 168 if (null !== $ip) 165 $req .= 'AND rateit_ip=\''.$this->co re->con->escape($ip).'\' ';166 167 $rs = $this->co re->con->select($req);169 $req .= 'AND rateit_ip=\''.$this->con->escape($ip).'\' '; 170 171 $rs = $this->con->select($req); 168 172 $this->core->blog->triggerBlog(); 169 173 } … … 183 187 184 188 if (!empty($params['rateit_type'])) { 185 $params['sql'] .= "AND rateit_type = '".$this->co re->con->escape($params['rateit_type'])."' ";189 $params['sql'] .= "AND rateit_type = '".$this->con->escape($params['rateit_type'])."' "; 186 190 unset($params['rateit_type']); 187 191 } 188 192 189 193 if (!empty($params['post_type'])) { 190 $params['sql'] .= "AND post_type = '".$this->co re->con->escape($params['post_type'])."' ";194 $params['sql'] .= "AND post_type = '".$this->con->escape($params['post_type'])."' "; 191 195 unset($params['post_type']); 192 196 } … … 253 257 254 258 $strReq .= 255 " WHERE RI.blog_id = '".$this-> core->con->escape($this->core->blog->id)."' ";259 " WHERE RI.blog_id = '".$this->blog."' "; 256 260 257 261 # rate type … … 259 263 260 264 if (is_array($params['rateit_type']) && !empty($params['rateit_type'])) 261 $strReq .= 'AND RI.rateit_type '.$this->co re->con->in($params['rateit_type']);265 $strReq .= 'AND RI.rateit_type '.$this->con->in($params['rateit_type']); 262 266 elseif ($params['rateit_type'] != '') 263 $strReq .= "AND RI.rateit_type = '".$this->co re->con->escape($params['rateit_type'])."' ";267 $strReq .= "AND RI.rateit_type = '".$this->con->escape($params['rateit_type'])."' "; 264 268 } else 265 269 $strReq .= "AND RI.rateit_type = 'post' "; … … 273 277 $params['rateit_id'] = array((integer) $params['rateit_id']); 274 278 275 $strReq .= 'AND RI.rateit_id '.$this->co re->con->in($params['rateit_id']);279 $strReq .= 'AND RI.rateit_id '.$this->con->in($params['rateit_id']); 276 280 } 277 281 … … 284 288 $params['rateit_ip'] = array((integer) $params['rateit_ip']); 285 289 286 $strReq .= 'AND RI.rateit_ip '.$this->co re->con->in($params['rateit_ip']);290 $strReq .= 'AND RI.rateit_ip '.$this->con->in($params['rateit_ip']); 287 291 } 288 292 … … 296 300 297 301 if (!empty($params['order'])) 298 $strReq .= 'ORDER BY '.$this->co re->con->escape($params['order']).' ';302 $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 299 303 else 300 304 $strReq .= 'ORDER BY rateit_time DESC '; … … 302 306 303 307 if (!$count_only && !empty($params['limit'])) 304 $strReq .= $this->co re->con->limit($params['limit']);308 $strReq .= $this->con->limit($params['limit']); 305 309 306 310 $rs = $this->core->con->select($strReq); … … 322 326 $req .= 'rateit_id,rateit_type,rateit_note,rateit_quotient,rateit_ip,rateit_time '; 323 327 324 $req .= 'FROM '.$this->table.' WHERE blog_id=\''.$this-> core->blog->id.'\' ';328 $req .= 'FROM '.$this->table.' WHERE blog_id=\''.$this->blog.'\' '; 325 329 326 330 if (null !== $type) 327 $req .= 'AND rateit_type=\''.$this->co re->con->escape($type).'\' ';331 $req .= 'AND rateit_type=\''.$this->con->escape($type).'\' '; 328 332 if (null !== $id) 329 $req .= 'AND rateit_id=\''.$this->co re->con->escape($id).'\' ';333 $req .= 'AND rateit_id=\''.$this->con->escape($id).'\' '; 330 334 if (null !== $ip) 331 $req .= 'AND rateit_ip=\''.$this->co re->con->escape($ip).'\' ';332 333 $rs = $this->co re->con->select($req);335 $req .= 'AND rateit_ip=\''.$this->con->escape($ip).'\' '; 336 337 $rs = $this->con->select($req); 334 338 335 339 if ($count_only) -
plugins/rateIt/release.txt
r1458 r1486 1 x.x.x xxxxxxxx 2 - Not fixed bug with rate by cookie 3 4 0.9.6 20090923 5 * Fixed DC 2.1.6 URL handlers ending 6 * Added sort by sort rate by date (thanks to lottie14) 7 * Cleaned some stuff 8 1 9 0.9.5 20090915 2 10 * Fixed erreur 1071 in some MySQL servers
Note: See TracChangeset
for help on using the changeset viewer.