Plugin Directory

Changeset 182475


Ignore:
Timestamp:
12/14/2009 05:10:05 AM (16 years ago)
Author:
tomheng
Message:
 
Location:
ecall/tags/1.12.15
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • ecall/tags/1.12.15/class.php

    r182465 r182475  
    7474    private $call_error;//调用出错,可以显示
    7575    private $copy;//版权信息
    76     public function __construct($key='',$cid='',$rows=8){
     76    private $rows;
     77    private $len;
     78    public function __construct($key='',$cid=0,$rows=8,$len=120){
    7779        $this->copy="<br/><a href='http://wordpress.org/extend/plugins/ecall/' title='wordpress Ecall插件'>Wordpress Ecall</a> <strong>Powered by</strong> <a href='http://http://blog.webfuns.cn/archives/313.html' title='获得更多帮助'>webfuns<a>";
    7880        $cfg=new Config();
    79    
     81        $this->rows=intval($rows);
     82        $this->len=intval($len);
    8083        $this->sys_cfg=$cfg->read();
     84        $this->cid=$cid;
    8185        if($this->sys_cfg['key']==$key){
    8286           //echo"访问合法";
    8387         
    8488           $this->cat=get_all_category_ids();
    85            if(array_value_exists($cid,$this->cat)&& !array_value_exists($cid,$this->sys_cfg['ban_cat'])||$cid==0){
     89           if(array_value_exists($this->cid,$this->cat)&& !array_value_exists($this->cid,$this->sys_cfg['ban_cat'])||$this->cid==0){
    8690           
    8791               //echo "cid合法";
    88                if($rows >$this->sys_cfg['max_rows']) $rows=$this->sys_cfg['max_rows'];
    89                $rank=$this->sys_cfg['rank'];
     92               if($this->rows >$this->sys_cfg['max_rows']) $this->rows=$this->sys_cfg['max_rows'];
     93               $this->rank=$this->sys_cfg['rank'];
    9094               if(intval($this->sys_cfg['cache_time'])>0){
    9195                    //是否超过系统最大配置数目
    9296                   
    93                     $cache_id=$cid.'_'.$rows;
     97                    $cache_id=$this->cid.'_'.$this->rows.$this->len;
    9498                    $this->cache=new Cache();
    9599                    $cache=$this->cache->read($cache_id);
     
    100104                          //echo"失效";
    101105                         
    102                           $html=$this->get_html($cid,$rank,$rows);
     106                          $html=$this->get_html();
    103107                          $this->cache->build($cache_id,$html);
    104108                    }else{
     
    122126       
    123127    }
    124     private function get_html($cid='',$rank='date',$rows=8){
     128    private function get_html(){
    125129         
    126           if($cid>=0){
    127             if($cid==0&&$this->sys_cfg['ban_cat']){
     130          if($this->cid>=0){
     131            if($this->cid==0&&$this->sys_cfg['ban_cat']){
    128132                 foreach($this->cat as $k => $v){
    129133                    if(!array_value_exists($v,$this->sys_cfg['ban_cat'])) $carray[]=$v;
    130134                 }
    131                $cid=join($carray,",");
    132                if(!$cid) {
     135               $this->cid=join($carray,",");
     136               if(!$this->cid) {
    133137                 //echo $cid.'helo';
    134138                    $this->error("博主可能关闭了插件,或者禁止了调用功能。");
     
    137141            }
    138142           
    139             $posts = get_posts("&category=".$cid."&numberposts=".$rows."&orderby=".$rank);
     143            $posts = get_posts("&category=".$this->cid."&numberposts=".$this->rows."&orderby=".$this->rank);
    140144           
    141145            foreach($posts as $post){
     
    146150                //print_r($post);
    147151                $parse['title']=get_the_title($id);
     152                //echo strlen($parse['title']);echo $this->len+3;
     153                /*if(strlen($parse['title'])>$this->len+3){
     154                    $parse['title']=substr($parse['title'],0,$this->len)."...";
     155                }*/
     156                $parse['title']=sysSubStr($parse['title'],$this->len);
    148157                $parse['pubdate']=date('Y-m-d',strtotime($post->post_date));
    149158                $parse['author']=get_the_author($id);
     
    223232      }
    224233}
     234function sysSubStr($String,$Length,$Append = false)
     235{
     236    if (strlen($String) <= $Length )
     237    {  // echo 'hello';
     238        return $String;
     239    }
     240    else
     241    {
     242        $I = 0;
     243        while ($I < $Length)
     244        {
     245            $StringTMP = substr($String,$I,1);
     246            if ( ord($StringTMP) >=224 )
     247            {
     248                $StringTMP = substr($String,$I,3);
     249                $I = $I + 3;
     250            }
     251            elseif( ord($StringTMP) >=192 )
     252            {
     253                $StringTMP = substr($String,$I,2);
     254                $I = $I + 2;
     255            }
     256            else
     257            {
     258                $I = $I + 1;
     259            }
     260            $StringLast[] = $StringTMP;
     261        }
     262        $StringLast = implode("",$StringLast);
     263        if($Append)
     264        {
     265            $StringLast .= "...";
     266        }
     267        return $StringLast;
     268    }
     269}
    225270?>
  • ecall/tags/1.12.15/config.data

    r182465 r182475  
    1 a:1:{s:3:"key";s:32:"15e3f539603bee92e0d5c6f2718a02e3";}
  • ecall/tags/1.12.15/ecall.php

    r182465 r182475  
    2727            $cid=$_GET['cid'];
    2828            $rows=$_GET['rows'];
     29            $len=$_GET['len'];
    2930            if(!$rows) $rows=8;
    30             $data=new MakeData($key,$cid,$rows);
     31            $data=new MakeData($key,$cid,$rows,$len);
    3132            exit;
    3233        }       
  • ecall/tags/1.12.15/html.php

    r182465 r182475  
    196196                $id=rand(0,count($cats)-1);*/
    197197                $id=0;
    198                 $call="<script type='text/javascript' src='".get_bloginfo('home')."/api.php?key=". $old_cfg['key']."&cid={$id}&rows=6'></script>";
     198                $call="<script type='text/javascript' src='".get_bloginfo('home')."/index.php?key=". $old_cfg['key']."&cid={$id}&rows=6'></script>";
    199199              echo $call=htmlspecialchars($call);
    200200             ?></textarea>
Note: See TracChangeset for help on using the changeset viewer.