Changeset 1492:a7112dcc916c for inc/core
- Timestamp:
- 08/20/13 11:01:52 (12 years ago)
- Branch:
- twig
- Parents:
- 1491:2b9253624dbe (diff), 1486:602b24e80834 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.blog.php
r1468 r1492 4 4 # This file is part of Dotclear 2. 5 5 # 6 # Copyright (c) 2003-201 3Olivier Meunier & Association Dotclear6 # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 7 7 # Licensed under the GPL version 2.0 license. 8 8 # See LICENSE file or … … 81 81 $this->desc = $b->blog_desc; 82 82 $this->url = $b->blog_url; 83 $this->host = http::getHostFromURL($this->url);83 $this->host = preg_replace('|^([a-z]{3,}://)(.*?)/.*$|','$1$2',$this->url); 84 84 $this->creadt = strtotime($b->blog_creadt); 85 85 $this->upddt = strtotime($b->blog_upddt); … … 842 842 843 843 if (!empty($params['user_id'])) { 844 $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."'";844 $strReq .= "AND U.user_id ".$this->con->in($params['user_id'])." "; 845 845 } 846 846 … … 926 926 $strReq .= 'ORDER BY post_dt DESC '; 927 927 } 928 } 929 930 if (!$count_only && !empty($params['limit'])) { 931 $strReq .= $this->con->limit($params['limit']); 928 if (!empty($params['limit'])) { 929 $strReq .= $this->con->limit($params['limit']); 930 } 932 931 } 933 932 -
inc/core/class.dc.blog.php
r1491 r1492 634 634 private function checkCategory($title,$url,$id=null) 635 635 { 636 $strReq = 'SELECT cat_id '. 637 'FROM '.$this->prefix.'category '. 638 "WHERE cat_url = '".$this->con->escape($url)."' ". 639 "AND blog_id = '".$this->con->escape($this->id)."' "; 640 641 if ($id !== null) { 642 $strReq .= 'AND cat_id <> '.(integer) $id.' '; 643 } 636 # Let's check if URL is taken... 637 $strReq = 638 'SELECT cat_url FROM '.$this->prefix.'category '. 639 "WHERE cat_url = '".$this->con->escape($url)."' ". 640 ($id ? 'AND cat_id <> '.(integer) $id. ' ' : ''). 641 "AND blog_id = '".$this->con->escape($this->id)."' ". 642 'ORDER BY cat_url DESC'; 644 643 645 644 $rs = $this->con->select($strReq); 646 645 647 if (!$rs->isEmpty()) { 648 throw new Exception(__('Category URL must be unique.')); 649 } 646 if (!$rs->isEmpty()) 647 { 648 if ($this->con->driver() == 'mysql') { 649 $clause = "REGEXP '^".$this->con->escape($url)."[0-9]+$'"; 650 } elseif ($this->con->driver() == 'pgsql') { 651 $clause = "~ '^".$this->con->escape($url)."[0-9]+$'"; 652 } else { 653 $clause = "LIKE '".$this->con->escape($url)."%'"; 654 } 655 $strReq = 656 'SELECT cat_url FROM '.$this->prefix.'category '. 657 "WHERE cat_url ".$clause.' '. 658 ($id ? 'AND cat_id <> '.(integer) $id. ' ' : ''). 659 "AND blog_id = '".$this->con->escape($this->id)."' ". 660 'ORDER BY cat_url DESC '; 661 662 $rs = $this->con->select($strReq); 663 $a = array(); 664 while ($rs->fetch()) { 665 $a[] = $rs->cat_url; 666 } 667 668 natsort($a); 669 $t_url = end($a); 670 671 if (preg_match('/(.*?)([0-9]+)$/',$t_url,$m)) { 672 $i = (integer) $m[2]; 673 $url = $m[1]; 674 } else { 675 $i = 1; 676 } 677 678 return $url.($i+1); 679 } 680 681 # URL is empty? 682 if ($url == '') { 683 throw new Exception(__('Empty category URL')); 684 } 685 686 return $url; 650 687 } 651 688 … … 669 706 670 707 # Check if title or url are unique 671 $ this->checkCategory($cur->cat_title,$cur->cat_url,$id);708 $cur->cat_url = $this->checkCategory($cur->cat_title,$cur->cat_url,$id); 672 709 673 710 if ($cur->cat_desc !== null) {
Note: See TracChangeset
for help on using the changeset viewer.