public function delAction()
 {
     //获取文章id
     if ($this->getRequest()->isGet()) {
         $account_id = $this->_request->get('id');
         $nickname = $this->_request->get('nickname');
         $article = new Application_Model_DbTable_Account();
         $db = $article->getAdapter();
         //删除用户
         $where0 = $db->quoteInto('id = ?', $account_id);
         $db->delete('account', $where0);
         //删除文章
         $where1 = $db->quoteInto('account_id = ?', $account_id);
         $db->delete('article', $where1);
         //删除文章对应的评论
         $where2 = $db->quoteInto('account_id = ?', $account_id);
         $db->delete('comment', $where2);
         //删除用户目录
         $dir = BLOG_ROOT . '/public/' . $nickname;
         $this->delDirAndFile($dir);
     }
     //判断是否是ajax传值
     if ($this->getRequest()->isXmlHttpRequest() || $this->_getParam('ajax') == 1) {
         $this->_helper->layout->setLayout('empty_layout');
         $this->_helper->viewRenderer->setNoRender();
         $this->_response->appendBody(2);
     } else {
         $this->_helper->viewRenderer->setNoRender();
         $this->_forward('index');
     }
 }
 public function findAction()
 {
     $this->view->headTitle("密码找回");
     //$this->_helper->viewRenderer->setNoRender ();
     if ($this->getRequest()->isPost()) {
         $nickname = trim($this->_request->getParam('nickname'));
         $email = trim($this->_request->getParam('email'));
         $account = new Application_Model_DbTable_Account();
         $db = $account->getAdapter();
         $select = $db->select();
         $select->from('account', array('nickname', 'password'));
         $select->where('nickname = ?', $nickname);
         $select->where('email = ?', $email);
         $result = $db->fetchRow($select);
         if ($result) {
             $smtpemailto = $email;
             $mailsubject = "cblog登陆密码找回";
             $mailbody = "<h1>cblog博客登陆密码找回</h1><p>您的博客:<br/><span>登陆账户为: " . $result['nickname'] . "</span> <br/> <span>登陆密码为:  " . $result['password'] . "</span></p>";
             if ($this->send($smtpemailto, $mailsubject, $mailbody)) {
                 //		if($this->mailSend($smtpemailto,$mailsubject,$mailbody)){
                 $status = "ok";
                 $response = "密码已发到您的邮箱,请注意查收!";
             } else {
                 $status = "sorry";
                 $response = "邮箱服务出错,请稍后再试!";
             }
         } else {
             $status = "sorry";
             $response = "你输入的用户名和邮箱不匹配,请重试!";
         }
         //print_r($this->_request->getParams());
         //var_dump($result);
         if ($this->getRequest()->isXmlHttpRequest() || $this->_request->getParam('ajax') == 1) {
             $this->_helper->layout->setLayout('empty_layout');
             $this->_helper->viewRenderer->setNoRender();
             $this->_response->appendBody($status);
         } else {
             echo "<script type='text/javascript'>alert('{$response}')</script>";
         }
     }
 }
 public function saveAction()
 {
     $this->_helper->layout->setLayout('empty_layout');
     if ($this->getRequest()->isPost() || $this->getRequest()->isXmlHttpRequest()) {
         $path = $this->_request->getParam('path');
         if (dirname($path) != "/upload/image/head") {
             $ab_path = $_SERVER['DOCUMENT_ROOT'] . '/' . substr($path, 1);
             $filename = end(explode('/', $ab_path));
             $dest = $_SERVER['DOCUMENT_ROOT'] . '/upload/image/head/' . $filename;
             if (copy($ab_path, $dest)) {
                 touch($dest, filemtime($ab_path));
                 $this->delDir($_SERVER['DOCUMENT_ROOT'] . '/upload/temp/' . BLOGGER_NAME . '/');
                 //将头像插入数据库
                 $account = new Application_Model_DbTable_Account();
                 $result = $account->updatePhoto(BLOGGER_ID, '/upload/image/head/' . $filename);
                 if ($result) {
                     $response = '头像设置成功';
                 } else {
                     $response = "系统忙,请稍后再试!";
                 }
             } else {
                 $response = "系统出错,请稍后再试!";
             }
         } else {
             $response = "头像设置成功";
         }
         $this->_helper->viewRenderer->setNoRender();
         $this->_response->appendBody($response);
     }
 }
 public function indexAction()
 {
     $cache = Zend_Registry::get('cache');
     $id = md5("aboutmeControllerIndex");
     if (($result = $cache->load($id)) === false) {
         //$data = $db->fetchAll($select);
         $account = new Application_Model_DbTable_Account();
         $db = $account->getAdapter();
         //获取用户信息
         $select = $db->select();
         $select->from('account', array('nickname', 'photo'));
         $select->where('id = ?', BLOGGER_ID);
         $result = $db->fetchRow($select);
         //获取博主 原创 翻译 转载各自篇数,和评论数
         $select = $db->select();
         $select->from('article', array('count(*) totalori'));
         $select->where('atype_id = 1');
         $select->where('account_id = ?', BLOGGER_ID);
         $arr = $db->fetchRow($select);
         $result['totalori'] = $arr['totalori'];
         $select = $db->select();
         $select->from('article', array('count(*) totaltrans'));
         $select->where('atype_id = 2');
         $select->where('account_id = ?', BLOGGER_ID);
         $arr = $db->fetchRow($select);
         $result['totaltrans'] = $arr['totaltrans'];
         $select = $db->select();
         $select->from('article', array('count(*) totalresp'));
         $select->where('atype_id = 3');
         $select->where('account_id = ?', BLOGGER_ID);
         $arr = $db->fetchRow($select);
         $result['totalresp'] = $arr['totalresp'];
         $comment = new Application_Model_CommentMapper();
         $comment_info = $comment->findBloggerAritcleComment(BLOGGER_ID);
         $totalComment = count($comment_info);
         $result['totalcom'] = $totalComment;
         //获取博客访问量
         //获取博主已访问过的ip
         $select = $db->select();
         $select->from('view_statistic', 'ip');
         $select->where('account_id = ?', BLOGGER_ID);
         $ips = $db->fetchAll($select);
         //获取当前访问ip
         include_once APPLICATION_PATH . '/../library/Cblog/RealIp.php';
         $ipObj = new Cblog_RealIp();
         $ip = $ipObj->getIp();
         foreach ($ips as $arr) {
             if ($ip == $arr['ip']) {
                 $status = "yes";
                 break;
             }
         }
         $select = $db->select();
         $select->from('view_statistic', 'count(id) as totalview');
         $select->where('account_id = ?', BLOGGER_ID);
         $totalViews = $db->fetchOne($select);
         //print_r($status);
         if (!isset($status)) {
             $viewstastic = new Application_Model_DbTable_ViewStatistic();
             $viewstastic->addViewIp(BLOGGER_ID, $ip);
             $result['totalview'] = $totalViews + 1;
         } else {
             $result['totalview'] = $totalViews;
         }
         $cache->save($result, $id, array('aboutmebox'));
     }
     //print_r($result);
     $this->view->data = $result;
 }