Skip to content

Instantly share code, notes, and snippets.

@Fendo181
Last active March 19, 2016 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fendo181/ef63a58921c755c0d658 to your computer and use it in GitHub Desktop.
Save Fendo181/ef63a58921c755c0d658 to your computer and use it in GitHub Desktop.
FuelPHP+MySQLで作る要望掲示板
# Multiple Environment config, set this to development, staging or production
# SetEnv FUEL_ENV production
<IfModule mod_rewrite.c>
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /wherever/fuel/is
# Make sure directory listing is disabled
Options +FollowSymLinks -Indexes
# Restrict your site to only one domain
# !important USE ONLY ONE OPTION
# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Remove index.php from URL
#RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
#RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
#RewriteRule ^index\.php(.*)$ $1 [R=301,NS,L]
# make HTTP Basic Authentication work on php5-fcgi installs
<IfModule mod_fcgid.c>
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Send request via index.php if not a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# deal with php5-cgi first
<IfModule mod_fcgid.c>
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
<IfModule !mod_fcgid.c>
# for normal Apache installations
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# for Apache FGCI installations
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
</IfModule>
</IfModule>
<div class="row">
<h3><?php echo $title ?>とは?</h3>
<p>
<h2>
世界は変える事ができないが、遠藤は変える事ができるかもしれないっ!
</h2>
<p>
<h3>
そんな気持ちと土日を犠牲にして、webサービス作ってみた。
</h3>
</p>
</p>
<h3>【管理者】</h3>
<p>
<h2>
遠藤 太徳。
好きなゼリーはミックスゼリー
</h2>
</p>
<h3>【現在の機能】</h3>
<h2>遠藤に対する要求</h2>
<p>
<h3>
※ほとんど通らない物と思ってください。
</h3>
</p>
<p>
<h3>
<ul>
<li>投稿者の名前を入力する必要はありません。IPアドレスがそのまま登録されます。</li>
<li>タイトルの入力をする必要がありません。入力した先頭12文字がタイトルに置き換わります。</li>
<li>悪質な投稿があれば遠藤が全力であなたの住所を特定しtwitterで晒しあげます。</li>
</ul>
</h3>
</p>
<h3>【今後追加する機能】</h3>
<p>
<h3>
掲示板,緊急連絡先一覧,chat,Webcamで見る遠藤の生態とは!
</h3>
</p>
</div>
<div class="row">
<div class="col-md-8">
<img class="img-responsive img-rounded" src="/assets/img/logo1.png" alt="">
</div>
</div>
<?php
class Controller_Request extends Controller_Template
{
public function action_index()
{
$data['requests'] = Model_Request::find('all');
$this->template->title = "Requests";
$this->template->content = View::forge('request/index', $data);
}
public function action_create()
{
if (Input::method() == 'POST')
{
$val = Model_Request::validate('create');
if ($val->run())
{
$request = Model_Request::forge(array(
'body' => Input::post('body'),
'ip' => Input::ip()
));
if ($request and $request->save())
{
Session::set_flash('success', 'Added request #'.$request->id.'.');
Response::redirect('request');
}
else
{
Session::set_flash('error', 'Could not save request.');
}
}
else
{
Session::set_flash('error', $val->error());
}
}
$this->template->title = "Requests";
$this->template->content = View::forge('request/create');
}
public function action_edit($id = null)
{
is_null($id) and Response::redirect('request');
if ( ! $request = Model_Request::find($id))
{
Session::set_flash('error', 'Could not find request #'.$id);
Response::redirect('request');
}
$val = Model_Request::validate('edit');
if ($val->run())
{
$request->body = Input::post('body');
$request->ip = Input::post('ip');
if ($request->save())
{
Session::set_flash('success', 'Updated request #' . $id);
Response::redirect('request');
}
else
{
Session::set_flash('error', 'Could not update request #' . $id);
}
}
else
{
if (Input::method() == 'POST')
{
$request->body = $val->validated('body');
$request->ip = $val->validated('ip');
Session::set_flash('error', $val->error());
}
$this->template->set_global('request', $request, false);
}
$this->template->title = "Requests";
$this->template->content = View::forge('request/edit');
}
public function action_delete($id = null)
{
is_null($id) and Response::redirect('request');
if ($request = Model_Request::find($id))
{
$request->delete();
Session::set_flash('success', 'Deleted request #'.$id);
}
else
{
Session::set_flash('error', 'Could not delete request #'.$id);
}
Response::redirect('request');
}
<?php
class Controller_Tweet extends Controller_Template
{
public function action_index()
{
$data["subnav"] = array('index'=> 'active' );
$this->template->title = '遠藤連絡';
$this->template->content = View::forge('tweet/index', $data);
}
public function action_about()
{
$this->template->title ='遠藤連絡';
$data["title"]=$this->template->title;
$this->template->content = View::forge('tweet/about',$data);
}
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>
<?php echo $title; ?>
</title>
<?php echo Asset::css('bootstrap.min.css'); ?>
<?php echo Asset::css('small-business.css'); ?>
<style>
body {
margin: 0px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<img src="/assets/img/logo2.jpg" alt="" width="150" height="70">
</a>
</div>
<div class="container">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><h3><a href="/">TopPage/</a></h3></li>
<li><h3><a href="/request">遠藤連絡/</a></h3></li>
<li><h3><a href="/tweet/about">About 遠藤連絡</a></h3></li>
</ul>
</div>
</div>
</nav>
<div class="container" <div class="col-md-12">
<?php echo $content; ?>
</div>
</div>
</body>
<h2>遠藤に対する要求をぶつけよう!!<span class='muted'>要求内容</span></h2>
<br>
<?php echo render('request/_form'); ?>
<p><?php echo Html::anchor('request', 'Back'); ?></p>
<h2>遠藤に対する要求を少し変えてみよう!!<span class='muted'>要求内容</span></h2>
<br>
<?php echo render('request/_form'); ?>
<p>
<?php echo Html::anchor('request', 'Back'); ?></p>
<div class="container">
<div class="row">
<div class="col-md-8">
<img src="/assets/img/logo3.JPG" alt="" width="400" height="400">
</div>
<div class="col-md-4">
<h1>Please Request!</h1>
<p>
<h2>ここでは日ごろ貴方が思っている遠藤に対する不満や改善してほしい点を投稿して頂ければ、気が向いたら遠藤がその投稿を見て改善します。ただし、ほとんど変わらないか、寧ろ悪化するものだと考えて下さい。
</h2>
</p>
<form action="" method="post">
<div class="col-md-12">
<h2>
<?php echo Html::anchor('request/create','Add new Request',array('class' => 'btn-success')); ?>
</h2>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="well txt-center">
<h3>
そう簡単に遠藤が動くと思わないで下さい。
</h3>
</div>
</div>
</div>
<div class="row">
<?php foreach ($requests as $item){ ?>
<div class="col-md-4">
<h3><?php echo substr($item->body,0,36); ?></h3>
<p>【投稿日時】
<?php echo date("Y-m-d H:i"),$item->created_at; ?>
</p>
<p>【IP】
<?php echo $item->ip; ?>
</p>
<p>
<?php echo substr($item->body,0,240); ?>
</p>
<?php echo Html::anchor('request/edit/'.$item->id, '<i class="icon-wrench"></i> Edit',array('class' => 'btn btn-default btn-sm'));
?>
<?php echo Html::anchor('request/delete/'.$item->id,'<i class="icon-trash icon-white"></i> Delete',array('class' =>'btn btn-sm btn-
danger','onclick'=>"return confirm('このデータを消去してもよろしいでしょうか?')"));
?>
</div>
<?php } ?>
</div>
<!-- /.row -->
</div>
h2>Viewing <span class='muted'>#<?php echo $request->id; ?></span></h2>
<p>
<strong>Body:</strong>
<?php echo $request->body; ?></p>
<p>
<strong>Ip:</strong>
<?php echo $request->ip; ?></p>
<?php echo Html::anchor('request/edit/'.$request->id, 'Edit'); ?> |
<?php echo Html::anchor('request', 'Back'); ?>
<?php echo Form::open(array("class"=>"form-horizontal")); ?>
<fieldset>
<div class="form-group">
<?php echo Form::label('要求内容', 'body', array('class'=>'control-label')); ?>
<?php echo Form::input('body', Input::post('body', isset($request) ? $request->body : ''), array('class' => 'col-md-4 form-control', 'placeholder'=>'Body')); ?>
</div>
<div class="form-group">
<label class='control-label'>&nbsp;</label>
<?php echo Form::submit('submit', '投稿する。', array('class' => 'btn btn-primary')); ?> </div>
</fieldset>
<?php echo Form::close(); ?>
@Fendo181
Copy link
Author

開発環境

vagrant+CentOS (7.0 64bit)+php5.3+mysql

全体ソース
URL:https://github.com/Fendo181/PHP_APP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment