<?php
//=============================
//基本設定
//=============================
$my_url = $_SERVER{'PHP_SELF'};
define(MAX_SIZE,130);
//画像の種類の定義
$image_type = array("image/gif" , "image/jpeg" , "ipeg/png");
//ファイル読み込み
require_once("./init.php");
//=============================
//基本設計
//=============================
//セッションスタート
session_start();
$h = new html();
$gaz = new gazou();
//サーバ側から
if($_SERVER['REQUEST_METHOD'] == "GET"){
$_POST['mode'] = &$_GET['mode'];
}
$h->header_html(THEMETITLE);
switch($_POST['mode']):
case 'write':
//追加処理
$gaz->g_add();
break;
default:
//一覧表示
$gaz->write_html();
break;
endswitch;
$h->footer_html();
exit;
class gazou {
var $id;
var $picNo;
var $pic;
var $name;
//================================================//
//□コンストラクタ
//================================================//
function __construct() {
//------------------------------------------------------
/* $img1tmp = $_FILES['img1']['tmp_name']; //tmpファイル名
$img1name = $_FILES['img1']['name']; //ローカルファイル名
$img1size = $_FILES['img1']['size']; //サイズ
$img1type = $_FILES['img1']['type']; //タイプ
*/
$this->id = $_SESSION["session_id"]; //ユーザID
$this->picNo = $_POST['picNo']; //画像
$this->pic = $_POST['pic']; //画像のアドレス
$this->name = $_POST['name']; //画像名
}
//================================================//
//□投稿画面
//================================================//
function write_html($error ="") {
global $gaz,$name;
echo<<<HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>画像のアップロード</TITLE>
<link rel="alternate stylesheet" type="text/css" title="medium" href="style/medium.css">
<link rel="alternate stylesheet" type="text/css" title="large" href="style/large.css">
<link rel="stylesheet" type="text/css" title="small" href="style/small.css">
<script type="text/javascript" src="style/j-script.js" ></script>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=Shift_JIS">
<LINK rel="stylesheet" type="text/css" href="style/style.css">
</HEAD>
<BODY>
<div align="center">
<div class="template">
<!--ここからメイン-->
<table border="0" width="750px">
<tr>
<!--メニューバー-->
<td valign="top" width="140px">
<br>
<div class="u-menu2">
<!--ブログの編集メニュー-->
<div class="gra-box2"><img src="./image/doa.gif" alt="ブログ編集">
ブログ編集
</div>
<table border="0">
<tr>
<td>
<img src="./image/book.gif" alt="過去のブログ">
<a href="b-hensyu.html">過去のブログ</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="プロフィール">
<a href="profile.php">プロフィール</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
<!--設定メニュー-->
<div class="u-menu1">
<div class="gra-box1"><img src="./image/doa.gif" alt="設定">
設定
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="ブログの設定">
<a href="b-set.html">ブログの設定</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="デザイン">
<a href="kari.htm">デザイン</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
<!--その他メニュー-->
<div class="u-menu3">
<div class="gra-box3"><img src="./image/doa.gif" alt="設定">
その他
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="">
<a href="kari.htm">画像アップロード</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="ユーザー設定">
<a href="u-set.html">ユーザー設定</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="ブログの削除">
<a href="delete.html">ブログの削除</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
</td>
<!--ここから右のページ-->
<td valign="top">
<!--パン屑プログラム-->
<div class="waku2">
<a href="u-top.html">
管理ツールトップ
</a>
>画像のアップロード
<div class="hr1"></div>
<!--ここまではテンプレ(パン屑プログラムも)-->
<BR>
<div class="u-menu2">
<h4 class="gray">項目選択</h4>
<table class="orange">
<th>
<img src="image/yajirushi.gif">
<a href="#gazou1" class="nolink">画像のアップロード</a>
</th>
<th>
<img src="image/yajirushi.gif"><a href="#gazou2" class="nolink">アップロードした画像一覧</a>
</th>
<th>
<img src="image/yajirushi.gif"><a href="#gazou3" class="nolink">プロフィールの画像選択</a>
</th>
</table>
</div>
<!--画像のアップロード-->
<h2>
<a name="gazou1">画像のアップロード</a>
</h2>
</div>
<!--アップロードフォーム-->
<div class="logbox">
<div class="gra-box2">
画像アップロード
</div>
アップロードできる画像の形式はjpg、gif、pngです。
サイズは自動的に150ピクセル×150ピクセルになります。<br>
<!--エラー表示-->
<h3>{$error}</h3>
<br>
<!--フォーム-->
<FORM action="$my_url" method="POST">
<input type=hidden name="mode" value="write">
<table border="0" cellspacing="3">
<tr>
<td>
<h4 class="gray">画像の参照</h4>
</td>
<td>
<h4 class="gray">画像につける名前</h4>
</td>
</tr>
<!--1行目-->
<tr>
<td>
<input type="file" name="pic" size=30><img src="image/migiya.gif">
</td>
<td>
<input type="text" size=30 maxlength="16" name="name" value="$lines[$pro_name]">
</td>
</tr>
<!--2行目-->
<tr>
<td>
<input type="file" name="pic" size=30><img src="image/migiya.gif">
</td>
<td>
<input type="text" size=30 maxlength="16" name="name" value="$lines[$gaz_name]">
</td>
</tr>
<!--3行目-->
<tr>
<td>
<input type="file" name="pic" size=30><img src="image/migiya.gif">
</td>
<td>
<input type="text" size=30 maxlength="16" name="name" value="$lines[$pro_name]">
</td>
</tr>
</table>
<p>
<div class="hr1"></div>
<input type="submit" name="submit" value="アップロード">
<input type="reset" value="クリア">
</p>
</FORM>
</div>
<!--アップロードフォーム終了-->
<!--最初はここに何も入ってません-->
<!--終了-->
<hr class="line">
<!--画像一覧-->
<div class="waku2">
<form>
<h2><a name="gazou2">アップロードした画像一覧</a></h2>
<div class="u-menu2">
<div class="gra-box2">画像一覧</div>
<table cellspacing="20" border="0">
<!--ボタン(アップする画像の数によって何行目にボタンが来るかが変わる-->
<tr>
<td colspan="3">
<div class="hr1"></div>
<h4 class="gray">
・名前を変更する場合は画像をクリックしてください<br>
・削除する場合はチェックボックスで選び、削除ボタンを押してください
</h4>
<input value="削除する" type="submit"><br>
</td>
</tr>
</table>
</form>
</div>
</div>
<!--画像一覧終了-->
<hr class="line">
<!--プロフィールに登録する画像-->
<form>
<div class="waku2">
<br>
<h2><a name="gazou3">プロフィール画像の選択</a></h2>
<div class="u-menu2">
<div class="gra-box2">プロフィール画像</div>
<!--画像を選ぶラジオボタン-->
<table border="0">
<tr>
<td valign="top" width="65%">
<td width="30%">
</td>
</tr>
</table>
<div class="hr1"></div>
<!--決定ボタン-->
<h4 class="gray">プロフィールの画像を選択し、登録ボタンを押してください</h4>
<input type="submit" value="プロフィールに登録する">
<input type="reset" value="クリア">
</div>
</div>
</form>
<br><br><br><br><br><br>
<!--終了。-->
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
HTML;
}
//================================================//
//画像のエラー処理
//================================================//
function error_check(){
if(strlen($this->name) > 50)
{
$error .="名前を25文字以内にしてください。<br/>";
}
echo $error;
if($error != "") {
$this->write_html($error);
exit();
}
}
//================================================//
//画像の追加処理
//================================================//
function g_add()
{
global $gaz,$myurl;
//error_checkに飛ばす
$this->error_check();
//MYSQLに接続
$conn = SQL_init::connect();
echo $_POST['name'];
exit();
//データベースに追加
$sql = "insert into {$gaz['colum']}"
." ({$gaz['id']},{$gaz['picNo']}, {$gaz['pic']},{$gaz['name']})"
." values ('$this->id','$this->picNo','$this->pic','$this->name')"
." where {$gaz['id']} = '$this->id'";
//クエリ送信
$aa = mysql_query($sql, $conn);
if($aa)
{
echo"<h3>追加しました。</h3><br>";
echo"<h3>しばらくお待ちください。</h3>";
} else {
die("追加できませんでした。");
}
//sql接続切る
mysql_close($conn);
//管理トップに戻す。
html::back_html($myurl);
}
//================================================//
}
?>
NAME="objform" ENCTYPE="multipart/form-data"
else if($this->thum == "") {
$error .="名前が入力されていません。<br/>";
}
//ファイルが合った場合は画像の縦横のサイズを取得する。
list($width, $height) = getimagesize(UPLOAD_DIR.$file);
//簡単なサムネイル表示を行うために縦横のサイズの計算をする。
$ratio = MAX_SIZE / max($width, $height);
$width = (int)($width * $ratio);
$height = (int)($height * $ratio);
//=============================
//基本設定
//=============================
$my_url = $_SERVER{'PHP_SELF'};
define(MAX_SIZE,130);
//画像の種類の定義
$image_type = array("image/gif" , "image/jpeg" , "ipeg/png");
//ファイル読み込み
require_once("./init.php");
//=============================
//基本設計
//=============================
//セッションスタート
session_start();
$h = new html();
$gaz = new gazou();
//サーバ側から
if($_SERVER['REQUEST_METHOD'] == "GET"){
$_POST['mode'] = &$_GET['mode'];
}
$h->header_html(THEMETITLE);
switch($_POST['mode']):
case 'write':
//追加処理
$gaz->g_add();
break;
default:
//一覧表示
$gaz->write_html();
break;
endswitch;
$h->footer_html();
exit;
class gazou {
var $id;
var $picNo;
var $pic;
var $name;
//================================================//
//□コンストラクタ
//================================================//
function __construct() {
//------------------------------------------------------
/* $img1tmp = $_FILES['img1']['tmp_name']; //tmpファイル名
$img1name = $_FILES['img1']['name']; //ローカルファイル名
$img1size = $_FILES['img1']['size']; //サイズ
$img1type = $_FILES['img1']['type']; //タイプ
*/
$this->id = $_SESSION["session_id"]; //ユーザID
$this->picNo = $_POST['picNo']; //画像
$this->pic = $_POST['pic']; //画像のアドレス
$this->name = $_POST['name']; //画像名
}
//================================================//
//□投稿画面
//================================================//
function write_html($error ="") {
global $gaz,$name;
echo<<<HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>画像のアップロード</TITLE>
<link rel="alternate stylesheet" type="text/css" title="medium" href="style/medium.css">
<link rel="alternate stylesheet" type="text/css" title="large" href="style/large.css">
<link rel="stylesheet" type="text/css" title="small" href="style/small.css">
<script type="text/javascript" src="style/j-script.js" ></script>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=Shift_JIS">
<LINK rel="stylesheet" type="text/css" href="style/style.css">
</HEAD>
<BODY>
<div align="center">
<div class="template">
<!--ここからメイン-->
<table border="0" width="750px">
<tr>
<!--メニューバー-->
<td valign="top" width="140px">
<br>
<div class="u-menu2">
<!--ブログの編集メニュー-->
<div class="gra-box2"><img src="./image/doa.gif" alt="ブログ編集">
ブログ編集
</div>
<table border="0">
<tr>
<td>
<img src="./image/book.gif" alt="過去のブログ">
<a href="b-hensyu.html">過去のブログ</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="プロフィール">
<a href="profile.php">プロフィール</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
<!--設定メニュー-->
<div class="u-menu1">
<div class="gra-box1"><img src="./image/doa.gif" alt="設定">
設定
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="ブログの設定">
<a href="b-set.html">ブログの設定</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="デザイン">
<a href="kari.htm">デザイン</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
<!--その他メニュー-->
<div class="u-menu3">
<div class="gra-box3"><img src="./image/doa.gif" alt="設定">
その他
</div>
<table border="0">
<tr>
<td>
<img src="./image/pen.gif" alt="">
<a href="kari.htm">画像アップロード</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="ユーザー設定">
<a href="u-set.html">ユーザー設定</a>
<div class="hr2"></div>
</td>
</tr>
<tr>
<td>
<img src="./image/book.gif" alt="ブログの削除">
<a href="delete.html">ブログの削除</a>
<div class="hr2"></div>
</td>
</tr>
</table>
</div>
</td>
<!--ここから右のページ-->
<td valign="top">
<!--パン屑プログラム-->
<div class="waku2">
<a href="u-top.html">
管理ツールトップ
</a>
>画像のアップロード
<div class="hr1"></div>
<!--ここまではテンプレ(パン屑プログラムも)-->
<BR>
<div class="u-menu2">
<h4 class="gray">項目選択</h4>
<table class="orange">
<th>
<img src="image/yajirushi.gif">
<a href="#gazou1" class="nolink">画像のアップロード</a>
</th>
<th>
<img src="image/yajirushi.gif"><a href="#gazou2" class="nolink">アップロードした画像一覧</a>
</th>
<th>
<img src="image/yajirushi.gif"><a href="#gazou3" class="nolink">プロフィールの画像選択</a>
</th>
</table>
</div>
<!--画像のアップロード-->
<h2>
<a name="gazou1">画像のアップロード</a>
</h2>
</div>
<!--アップロードフォーム-->
<div class="logbox">
<div class="gra-box2">
画像アップロード
</div>
アップロードできる画像の形式はjpg、gif、pngです。
サイズは自動的に150ピクセル×150ピクセルになります。<br>
<!--エラー表示-->
<h3>{$error}</h3>
<br>
<!--フォーム-->
<FORM action="$my_url" method="POST">
<input type=hidden name="mode" value="write">
<table border="0" cellspacing="3">
<tr>
<td>
<h4 class="gray">画像の参照</h4>
</td>
<td>
<h4 class="gray">画像につける名前</h4>
</td>
</tr>
<!--1行目-->
<tr>
<td>
<input type="file" name="pic" size=30><img src="image/migiya.gif">
</td>
<td>
<input type="text" size=30 maxlength="16" name="name" value="$lines[$pro_name]">
</td>
</tr>
<!--2行目-->
<tr>
<td>
<input type="file" name="pic" size=30><img src="image/migiya.gif">
</td>
<td>
<input type="text" size=30 maxlength="16" name="name" value="$lines[$gaz_name]">
</td>
</tr>
<!--3行目-->
<tr>
<td>
<input type="file" name="pic" size=30><img src="image/migiya.gif">
</td>
<td>
<input type="text" size=30 maxlength="16" name="name" value="$lines[$pro_name]">
</td>
</tr>
</table>
<p>
<div class="hr1"></div>
<input type="submit" name="submit" value="アップロード">
<input type="reset" value="クリア">
</p>
</FORM>
</div>
<!--アップロードフォーム終了-->
<!--最初はここに何も入ってません-->
<!--終了-->
<hr class="line">
<!--画像一覧-->
<div class="waku2">
<form>
<h2><a name="gazou2">アップロードした画像一覧</a></h2>
<div class="u-menu2">
<div class="gra-box2">画像一覧</div>
<table cellspacing="20" border="0">
<!--ボタン(アップする画像の数によって何行目にボタンが来るかが変わる-->
<tr>
<td colspan="3">
<div class="hr1"></div>
<h4 class="gray">
・名前を変更する場合は画像をクリックしてください<br>
・削除する場合はチェックボックスで選び、削除ボタンを押してください
</h4>
<input value="削除する" type="submit"><br>
</td>
</tr>
</table>
</form>
</div>
</div>
<!--画像一覧終了-->
<hr class="line">
<!--プロフィールに登録する画像-->
<form>
<div class="waku2">
<br>
<h2><a name="gazou3">プロフィール画像の選択</a></h2>
<div class="u-menu2">
<div class="gra-box2">プロフィール画像</div>
<!--画像を選ぶラジオボタン-->
<table border="0">
<tr>
<td valign="top" width="65%">
<td width="30%">
</td>
</tr>
</table>
<div class="hr1"></div>
<!--決定ボタン-->
<h4 class="gray">プロフィールの画像を選択し、登録ボタンを押してください</h4>
<input type="submit" value="プロフィールに登録する">
<input type="reset" value="クリア">
</div>
</div>
</form>
<br><br><br><br><br><br>
<!--終了。-->
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
HTML;
}
//================================================//
//画像のエラー処理
//================================================//
function error_check(){
if(strlen($this->name) > 50)
{
$error .="名前を25文字以内にしてください。<br/>";
}
echo $error;
if($error != "") {
$this->write_html($error);
exit();
}
}
//================================================//
//画像の追加処理
//================================================//
function g_add()
{
global $gaz,$myurl;
//error_checkに飛ばす
$this->error_check();
//MYSQLに接続
$conn = SQL_init::connect();
echo $_POST['name'];
exit();
//データベースに追加
$sql = "insert into {$gaz['colum']}"
." ({$gaz['id']},{$gaz['picNo']}, {$gaz['pic']},{$gaz['name']})"
." values ('$this->id','$this->picNo','$this->pic','$this->name')"
." where {$gaz['id']} = '$this->id'";
//クエリ送信
$aa = mysql_query($sql, $conn);
if($aa)
{
echo"<h3>追加しました。</h3><br>";
echo"<h3>しばらくお待ちください。</h3>";
} else {
die("追加できませんでした。");
}
//sql接続切る
mysql_close($conn);
//管理トップに戻す。
html::back_html($myurl);
}
//================================================//
}
?>
NAME="objform" ENCTYPE="multipart/form-data"
else if($this->thum == "") {
$error .="名前が入力されていません。<br/>";
}
//ファイルが合った場合は画像の縦横のサイズを取得する。
list($width, $height) = getimagesize(UPLOAD_DIR.$file);
//簡単なサムネイル表示を行うために縦横のサイズの計算をする。
$ratio = MAX_SIZE / max($width, $height);
$width = (int)($width * $ratio);
$height = (int)($height * $ratio);