Example #1
0
 public function action_imagelist()
 {
     $query = Model_Board::query()->select("id");
     $bbsCount = $query->count();
     //ページネーション
     $pConfig = array('pagination_url' => 'admin/imagelist/', 'uri_segment' => 3, 'num_links' => 2, 'per_page' => 3, 'total_items' => $bbsCount, 'show_first' => true, 'show_last' => true, 'name' => 'bootstrap3');
     $pagiNation = Pagination::forge('adminPagination', $pConfig);
     $query2 = Model_Board::query();
     $query2->rows_offset($pagiNation->offset);
     $query2->rows_limit($pagiNation->per_page);
     $query2->order_by('id', 'desc');
     $data['bbss'] = $query2->get();
     $query3 = Model_Attach::query();
     $query3->select('id', 'bbsId', 'mime');
     foreach ($data['bbss'] as $bbs) {
         $query3->or_where_open();
         $query3->where('bbsId', '=', $bbs->id);
         $query3->or_where_close();
     }
     $query3->order_by('id', 'desc');
     $data['attaches'] = $query3->get();
     $this->template->boardDescription = '画像一覧';
     $content = View::forge('admin/imglist', $data);
     $content->set_safe('pagination', $pagiNation);
     $this->template->content = $content;
 }
Example #2
0
 public function action_index($pr1 = null, $pr2 = null)
 {
     //パラメータが付いていた場合はリダイレクト
     if ($pr1 != null || $pr2 != null) {
         return Response::forge(Uri::base());
     }
     $msg = Session::get('errorMsg');
     Session::delete('errorMsg');
     /*		
     		//ログインフォーム作成
     		$loginFieldSet = Fieldset::forge('loginForm');
     		$loginFieldSet->add('username','',array('type'=>'text','size'=>20));
     		$loginFieldSet->add('password','',array('type'=>'password','size'=>20));
     		$loginFieldSet->repopulate();
     		//送信ボタン追加
     		$loginFieldSet->add('submit','',array('type'=>'submit','width'=>80,'value'=>' ログイン '));
     */
     $content = '';
     if (Agent::is_mobiledevice()) {
         $content = View::forge('index/index_mobile');
     } else {
         $content = View::forge('index/index_pc');
     }
     //掲示板全体の最新画像
     $query = Model_Attach::query();
     $query->select('id', 'bbsId');
     $query->limit(12);
     $query->order_by('created_at', 'desc');
     $images = $query->get();
     //最新の書き込み掲示板(10個)
     $query2 = Model_Board::query();
     $query2->select('id', 'shortName', 'title', 'updated_at');
     $query2->limit(10);
     $query2->order_by('updated_at', 'desc');
     $update = $query2->get();
     //投稿数順
     Model_Board::clear_cache();
     $query3 = Model_Board::query();
     $query3->select('id', 'shortName', 'title', 'postCount');
     $query3->limit(10);
     $query3->order_by('postCount', 'desc');
     $postCount = $query3->get();
     $this->setBoardTitle();
     //		$content->set('loginForm',$loginFieldSet->build('index/login'),false);
     $content->set('newestImages', $images);
     $content->set('updateBoards', $update);
     $content->set('postCount', $postCount);
     //エラーメッセージ設定
     if ($msg != null) {
         $content->set('msg', $msg, false);
     }
     $this->template->content = $content;
 }
Example #3
0
 public function action_thumbnail($imgId = 0)
 {
     $img = Model_Attach::find($imgId);
     $mime = $img['mime'];
     $body = $img['thumbData'];
     if (isset($mime) && isset($body)) {
         header($mime);
         echo $body;
         return Response::forge($body, 200, array('Content-Type' => $mime));
     }
     return Response::forge($body, 200, array('Content-Type' => $mime));
 }
Example #4
0
 public function deleteAttach()
 {
     $query = Model_Attach::query()->where('bbsId', $this->id);
     $ats = $query->get();
     foreach ($ats as $at) {
         $at->delete();
     }
 }
Example #5
0
File: bbs.php Project: katsuwo/bbs
 /**
  * スレッド元書き込み($threadId)とコメント(Model_Articleの配列)の添付ファイルを得る
  * (mimeとId,添付元IDのみを返す)
  * @param type $board Model_Board
  * @param type $threadId Model_Articleの配列のId(スレッド元)
  * @param type $comments Model_Articleの配列(コメント)
  * @return type Model_Attachの配列
  */
 public function getAttach($board = null, $threadId = null, $comments = null, $limit = null)
 {
     if ($board == null || $threadId == null) {
         return null;
     }
     $query = Model_Attach::query()->select('mime', 'id', 'attachOf')->where('bbsId', $board->id);
     $query->and_where_open();
     $query->where('attachOf', '=', $threadId);
     if ($comments != null) {
         foreach ($comments as $comment) {
             $query->or_where_open();
             $query->where('attachOf', '=', $comment->id);
             $query->or_where_close();
         }
     }
     $query->and_where_close();
     if ($limit != null) {
         $query->rows_limit($limit);
     }
     $query->order_by('id', 'desc');
     return $query->get();
 }
Example #6
0
<?php

if (isset($imgId) && isset($shortName)) {
    //掲示板を取得
    $query = Model_Board::query()->where('shortName', $shortName);
    $board = $query->get_one();
    if ($board == null) {
        echo 'パラメータ異常';
        return;
    }
    //画像のbbsIDを確認
    $img = Model_Attach::find($imgId);
    if ($img == null) {
        echo 'パラメータ異常';
        return;
    }
    if ($img->bbsId != $board->id) {
        echo 'パラメータ異常';
        return;
    }
    if (Auth::check()) {
        if ($board->userId == Auth::get('id')) {
            echo '<img src =\'/imgLoader/thumbnail/' . $imgId . '\' width=100/><BR>';
            echo '<BR>';
            echo '管理者権限で画像を削除しますか?<BR>';
            echo '<div id=\'redBox\'> <a href = \'' . Uri::current() . '?mode=delete\'>削除</a></div>';
            echo '<div id=\'shortBox\'> <a href = \'' . $backURL . '\'>キャンセル</a></div>';
            echo '<BR>';
            echo '<BR>';
            return;
        }