| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | <?phpDoo::loadModel('share');Doo::loadClass('Hashids/Hashids');/** * Description of Users * * @author zongheng */class Shareact{    private $__share, $__hashids, $__timetmp;    function __construct()    {        $this->__share = new Share();        $this->__hashids = new Hashids\Hashids('zhhashsalt');    }    public function insertHashcode($ids, $idtype)    {        $this->__timetmp = gettimeofday();        $this->__share->endtime = time();        $this->__share->intime = time();        $this->__share->hashcode = $this->__hashids->encode($this->__timetmp['sec']);        $this->__share->ids = $ids;        $this->__share->idtype = $idtype;        return array('status' => $this->__share->insert(), 'hashcode' => $this->__share->hashcode);    }    public function updateHashcode($ids, $idtype)    {        $this->__timetmp = gettimeofday();        $this->__share->hashcode = $this->__hashids->encode($this->__timetmp['sec']);        return array('status' => $this->__share->update(array('where' => 'ids=? AND idtype=?', 'param' => array($ids, $idtype))), 'hashcode' => $this->__share->hashcode);    }    public function deleteHashcode($ids,$idtype)    {        $hashcode = $this->getHashCode($ids,$idtype);        return $this->__share->delete(array('where' => 'sid=?', 'param' => array($hashcode['sid'])));    }    public function getCount($ids, $idtype)    {        return $this->__share->Count(array('where' => 'ids=? AND idtype=?', 'param' => array($ids, $idtype)));    }    public function getHashCode($ids,$idtype)    {        return $this->__share->getOne(array('where' => 'ids=? AND idtype=?', 'param' => array($ids, $idtype), 'asArray' => true));    }    public function getSectionCount($ids)    {        return $this->__share->getOne(array('where' => 'ids=? AND idtype=2', 'param' => array($ids), 'asArray' => true));    }    public function getCountByKey($key)    {        return $this->__share->Count(array('where' => 'hashcode=?', 'param' => array($key)));    }    public function getOne($key)    {        return $this->__share->getOne(array('where' => 'hashcode=?', 'param' => array($key), 'asArray' => true));    }}
 |